Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/3.0_mhli
This commit is contained in:
commit
b0d73826a7
|
@ -193,6 +193,7 @@ endif(${BUILD_WITH_TRAFT})
|
|||
|
||||
# LIBUV
|
||||
if(${BUILD_WITH_UV})
|
||||
add_compile_options(-Wno-sign-compare)
|
||||
add_subdirectory(libuv)
|
||||
endif(${BUILD_WITH_UV})
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ int32_t init_env() {
|
|||
}
|
||||
|
||||
int32_t create_topic() {
|
||||
printf("create topic");
|
||||
printf("create topic\n");
|
||||
TAOS_RES* pRes;
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
|
@ -91,6 +91,10 @@ int32_t create_topic() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tmq_commit_cb_print(tmq_t* tmq, tmq_resp_err_t resp, tmq_topic_vgroup_list_t* offsets, void* param) {
|
||||
printf("commit %d\n", resp);
|
||||
}
|
||||
|
||||
tmq_t* build_consumer() {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
@ -103,6 +107,7 @@ tmq_t* build_consumer() {
|
|||
|
||||
tmq_conf_t* conf = tmq_conf_new();
|
||||
tmq_conf_set(conf, "group.id", "tg2");
|
||||
tmq_conf_set_offset_commit_cb(conf, tmq_commit_cb_print);
|
||||
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
|
||||
return tmq;
|
||||
}
|
||||
|
@ -144,7 +149,7 @@ void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
|||
}
|
||||
|
||||
void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||
static const int MIN_COMMIT_COUNT = 1000;
|
||||
static const int MIN_COMMIT_COUNT = 1;
|
||||
|
||||
int msg_count = 0;
|
||||
tmq_resp_err_t err;
|
||||
|
@ -214,6 +219,6 @@ int main(int argc, char* argv[]) {
|
|||
tmq_t* tmq = build_consumer();
|
||||
tmq_list_t* topic_list = build_topic_list();
|
||||
/*perf_loop(tmq, topic_list);*/
|
||||
basic_consume_loop(tmq, topic_list);
|
||||
/*sync_consume_loop(tmq, topic_list);*/
|
||||
/*basic_consume_loop(tmq, topic_list);*/
|
||||
sync_consume_loop(tmq, topic_list);
|
||||
}
|
||||
|
|
|
@ -198,8 +198,8 @@ DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLi
|
|||
/* --------------------------TMQ INTERFACE------------------------------- */
|
||||
|
||||
enum tmq_resp_err_t {
|
||||
TMQ_RESP_ERR__FAIL = -1,
|
||||
TMQ_RESP_ERR__SUCCESS = 0,
|
||||
TMQ_RESP_ERR__FAIL = 1,
|
||||
};
|
||||
|
||||
typedef enum tmq_resp_err_t tmq_resp_err_t;
|
||||
|
@ -226,7 +226,7 @@ DLL_EXPORT const char *tmq_err2str(tmq_resp_err_t);
|
|||
DLL_EXPORT tmq_resp_err_t tmq_subscribe(tmq_t *tmq, tmq_list_t *topic_list);
|
||||
#if 0
|
||||
DLL_EXPORT tmq_resp_err_t tmq_unsubscribe(tmq_t* tmq);
|
||||
DLL_EXPORT tmq_resp_err_t tmq_subscription(tmq_t* tmq, tmq_topic_vgroup_list_t** topics);
|
||||
DLL_EXPORT tmq_resp_err_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics);
|
||||
#endif
|
||||
DLL_EXPORT tmq_message_t *tmq_consumer_poll(tmq_t *tmq, int64_t blocking_time);
|
||||
DLL_EXPORT tmq_resp_err_t tmq_consumer_close(tmq_t *tmq);
|
||||
|
@ -238,6 +238,7 @@ DLL_EXPORT tmq_resp_err_t tmq_commit(tmq_t *tmq, const tmq_topic_vgroup_list_t *
|
|||
#if 0
|
||||
DLL_EXPORT tmq_resp_err_t tmq_commit_message(tmq_t* tmq, const tmq_message_t* tmqmessage, int32_t async);
|
||||
#endif
|
||||
DLL_EXPORT tmq_resp_err_t tmq_seek(tmq_t *tmq, const tmq_topic_vgroup_t *offset);
|
||||
/* ----------------------TMQ CONFIGURATION INTERFACE---------------------- */
|
||||
|
||||
enum tmq_conf_res_t {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#ifndef TDENGINE_COMMON_H
|
||||
#define TDENGINE_COMMON_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -43,14 +42,16 @@ extern "C" {
|
|||
// int16_t bytes;
|
||||
// } SSchema;
|
||||
|
||||
#define TMQ_REQ_TYPE_COMMIT_ONLY 0
|
||||
#define TMQ_REQ_TYPE_CONSUME_ONLY 1
|
||||
#define TMQ_REQ_TYPE_CONSUME_AND_COMMIT 2
|
||||
enum {
|
||||
TMQ_CONF__RESET_OFFSET__LATEST = -1,
|
||||
TMQ_CONF__RESET_OFFSET__EARLIEAST = -2,
|
||||
TMQ_CONF__RESET_OFFSET__NONE = -3,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t numOfTables;
|
||||
SArray *pGroupList;
|
||||
SHashObj *map; // speedup acquire the tableQueryInfo by table uid
|
||||
SArray* pGroupList;
|
||||
SHashObj* map; // speedup acquire the tableQueryInfo by table uid
|
||||
} STableGroupInfo;
|
||||
|
||||
typedef struct SColumnDataAgg {
|
||||
|
@ -79,14 +80,14 @@ typedef struct SConstantItem {
|
|||
|
||||
// info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList);
|
||||
typedef struct SSDataBlock {
|
||||
SColumnDataAgg *pBlockAgg;
|
||||
SArray *pDataBlock; // SArray<SColumnInfoData>
|
||||
SArray *pConstantList; // SArray<SConstantItem>, it is a constant/tags value of the corresponding result value.
|
||||
SDataBlockInfo info;
|
||||
SColumnDataAgg* pBlockAgg;
|
||||
SArray* pDataBlock; // SArray<SColumnInfoData>
|
||||
SArray* pConstantList; // SArray<SConstantItem>, it is a constant/tags value of the corresponding result value.
|
||||
SDataBlockInfo info;
|
||||
} SSDataBlock;
|
||||
|
||||
typedef struct SVarColAttr {
|
||||
int32_t *offset; // start position for each entry in the list
|
||||
int32_t* offset; // start position for each entry in the list
|
||||
uint32_t length; // used buffer size that contain the valid data
|
||||
uint32_t allocLen; // allocated buffer size
|
||||
} SVarColAttr;
|
||||
|
@ -94,11 +95,11 @@ typedef struct SVarColAttr {
|
|||
// pBlockAgg->numOfNull == info.rows, all data are null
|
||||
// pBlockAgg->numOfNull == 0, no data are null.
|
||||
typedef struct SColumnInfoData {
|
||||
SColumnInfo info; // TODO filter info needs to be removed
|
||||
bool hasNull;// if current column data has null value.
|
||||
char *pData; // the corresponding block data in memory
|
||||
SColumnInfo info; // TODO filter info needs to be removed
|
||||
bool hasNull; // if current column data has null value.
|
||||
char* pData; // the corresponding block data in memory
|
||||
union {
|
||||
char *nullbitmap; // bitmap, one bit for each item in the list
|
||||
char* nullbitmap; // bitmap, one bit for each item in the list
|
||||
SVarColAttr varmeta;
|
||||
};
|
||||
} SColumnInfoData;
|
||||
|
@ -149,7 +150,6 @@ static FORCE_INLINE int32_t tEncodeSMqConsumeRsp(void** buf, const SMqConsumeRsp
|
|||
int32_t tlen = 0;
|
||||
int32_t sz = 0;
|
||||
tlen += taosEncodeFixedI64(buf, pRsp->consumerId);
|
||||
tlen += taosEncodeFixedI64(buf, pRsp->committedOffset);
|
||||
tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
|
||||
tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
|
||||
tlen += taosEncodeFixedI32(buf, pRsp->skipLogNum);
|
||||
|
@ -170,7 +170,6 @@ static FORCE_INLINE int32_t tEncodeSMqConsumeRsp(void** buf, const SMqConsumeRsp
|
|||
static FORCE_INLINE void* tDecodeSMqConsumeRsp(void* buf, SMqConsumeRsp* pRsp) {
|
||||
int32_t sz;
|
||||
buf = taosDecodeFixedI64(buf, &pRsp->consumerId);
|
||||
buf = taosDecodeFixedI64(buf, &pRsp->committedOffset);
|
||||
buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);
|
||||
buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
|
||||
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
|
||||
|
@ -250,11 +249,11 @@ typedef struct SSqlExpr {
|
|||
char token[TSDB_COL_NAME_LEN]; // original token
|
||||
SSchema resSchema;
|
||||
|
||||
int32_t numOfCols;
|
||||
SColumn* pColumns; // data columns that are required by query
|
||||
int32_t interBytes; // inter result buffer size
|
||||
int16_t numOfParams; // argument value of each function
|
||||
SVariant param[3]; // parameters are not more than 3
|
||||
int32_t numOfCols;
|
||||
SColumn* pColumns; // data columns that are required by query
|
||||
int32_t interBytes; // inter result buffer size
|
||||
int16_t numOfParams; // argument value of each function
|
||||
SVariant param[3]; // parameters are not more than 3
|
||||
} SSqlExpr;
|
||||
|
||||
typedef struct SExprInfo {
|
||||
|
@ -271,7 +270,7 @@ typedef struct SSessionWindow {
|
|||
SColumn col;
|
||||
} SSessionWindow;
|
||||
|
||||
#define QUERY_ASC_FORWARD_STEP 1
|
||||
#define QUERY_ASC_FORWARD_STEP 1
|
||||
#define QUERY_DESC_FORWARD_STEP -1
|
||||
|
||||
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
|
||||
|
|
|
@ -68,8 +68,8 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u
|
|||
}
|
||||
|
||||
#define colDataGet(p1_, r_) \
|
||||
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? (p1_)->pData + (p1_)->varmeta.offset[(r_)] \
|
||||
: (p1_)->pData + ((r_) * (p1_)->info.bytes));
|
||||
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? ((p1_)->pData + (p1_)->varmeta.offset[(r_)]) \
|
||||
: ((p1_)->pData + ((r_) * (p1_)->info.bytes)))
|
||||
|
||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource, uint32_t numOfRow2);
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tdef.h"
|
||||
#include "tcfg.h"
|
||||
#include "tdef.h"
|
||||
#include "tarray.h"
|
||||
|
||||
// cluster
|
||||
extern char tsFirst[];
|
||||
|
@ -29,44 +30,39 @@ extern char tsSecond[];
|
|||
extern char tsLocalFqdn[];
|
||||
extern char tsLocalEp[];
|
||||
extern uint16_t tsServerPort;
|
||||
extern int32_t tsVersion;
|
||||
extern int32_t tsStatusInterval;
|
||||
extern int8_t tsEnableTelemetryReporting;
|
||||
extern int32_t tsNumOfSupportVnodes;
|
||||
extern bool tsEnableTelemetryReporting;
|
||||
|
||||
// common
|
||||
extern int tsRpcTimer;
|
||||
extern int tsRpcMaxTime;
|
||||
extern int tsRpcForceTcp; // all commands go to tcp protocol if this is enabled
|
||||
extern int32_t tsMaxConnections;
|
||||
extern int32_t tsMaxShellConns;
|
||||
extern int32_t tsShellActivityTimer;
|
||||
extern uint32_t tsMaxTmrCtrl;
|
||||
extern float tsNumOfThreadsPerCore;
|
||||
extern int32_t tsNumOfCommitThreads;
|
||||
extern float tsRatioOfQueryCores;
|
||||
extern int8_t tsDaylight;
|
||||
extern int8_t tsEnableCoreFile;
|
||||
extern int32_t tsCompressMsgSize;
|
||||
extern int32_t tsCompressColData;
|
||||
extern int32_t tsMaxNumOfDistinctResults;
|
||||
extern char tsTempDir[];
|
||||
extern int tsCompatibleModel; // 2.0 compatible model
|
||||
extern int8_t tsEnableSlaveQuery;
|
||||
extern int8_t tsEnableAdjustMaster;
|
||||
extern int8_t tsPrintAuth;
|
||||
extern int64_t tsTickPerDay[3];
|
||||
extern int32_t tsRpcTimer;
|
||||
extern int32_t tsRpcMaxTime;
|
||||
extern bool tsRpcForceTcp; // all commands go to tcp protocol if this is enabled
|
||||
extern int32_t tsMaxConnections;
|
||||
extern int32_t tsMaxShellConns;
|
||||
extern int32_t tsShellActivityTimer;
|
||||
extern int32_t tsMaxTmrCtrl;
|
||||
extern float tsNumOfThreadsPerCore;
|
||||
extern int32_t tsNumOfCommitThreads;
|
||||
extern float tsRatioOfQueryCores;
|
||||
extern int32_t tsCompressMsgSize;
|
||||
extern int32_t tsCompressColData;
|
||||
extern int32_t tsMaxNumOfDistinctResults;
|
||||
extern int32_t tsCompatibleModel;
|
||||
extern bool tsEnableSlaveQuery;
|
||||
extern bool tsPrintAuth;
|
||||
extern int64_t tsTickPerDay[3];
|
||||
|
||||
// query buffer management
|
||||
extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing
|
||||
extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node
|
||||
extern int32_t tsRetrieveBlockingModel; // retrieve threads will be blocked
|
||||
extern int8_t tsKeepOriginalColumnName;
|
||||
extern int8_t tsDeadLockKillQuery;
|
||||
extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked
|
||||
extern bool tsKeepOriginalColumnName;
|
||||
extern bool tsDeadLockKillQuery;
|
||||
|
||||
// client
|
||||
extern int32_t tsMaxWildCardsLen;
|
||||
extern int32_t tsMaxRegexStringLen;
|
||||
extern int8_t tsTscEnableRecordSql;
|
||||
extern int32_t tsMaxNumOfOrderedResults;
|
||||
extern int32_t tsMinSlidingTime;
|
||||
extern int32_t tsMinIntervalTime;
|
||||
|
@ -77,19 +73,6 @@ extern float tsStreamComputDelayRatio; // the delayed computing ration of the
|
|||
extern int32_t tsProjectExecInterval;
|
||||
extern int64_t tsMaxRetentWindow;
|
||||
|
||||
// system info
|
||||
extern float tsTotalLogDirGB;
|
||||
extern float tsTotalTmpDirGB;
|
||||
extern float tsTotalDataDirGB;
|
||||
extern float tsAvailLogDirGB;
|
||||
extern float tsAvailTmpDirectorySpace;
|
||||
extern float tsAvailDataDirGB;
|
||||
extern float tsUsedDataDirGB;
|
||||
extern float tsMinimalLogDirGB;
|
||||
extern float tsReservedTmpDirectorySpace;
|
||||
extern float tsMinimalDataDirGB;
|
||||
extern uint32_t tsVersion;
|
||||
|
||||
// build info
|
||||
extern char version[];
|
||||
extern char compatible_version[];
|
||||
|
@ -105,18 +88,19 @@ extern uint32_t tsMaxRange;
|
|||
extern uint32_t tsCurRange;
|
||||
extern char tsCompressor[];
|
||||
|
||||
// tfs
|
||||
extern int32_t tsDiskCfgNum;
|
||||
extern SDiskCfg tsDiskCfg[];
|
||||
|
||||
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||
|
||||
void taosInitGlobalCfg();
|
||||
int32_t taosCheckAndPrintCfg();
|
||||
int32_t taosCfgDynamicOptions(char *msg);
|
||||
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
|
||||
void taosAddDataDir(int index, char *v1, int level, int primary);
|
||||
void taosReadDataDirCfg(char *v1, char *v2, char *v3);
|
||||
void taosPrintDataDirCfg();
|
||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char *envFile,
|
||||
const char *apolloUrl, SArray *pArgs, bool tsc);
|
||||
int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloUrl, SArray *pArgs, bool tsc);
|
||||
void taosCleanupCfg();
|
||||
void taosCfgDynamicOptions(const char *option, const char *value);
|
||||
|
||||
struct SConfig *taosGetCfg();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -422,8 +422,8 @@ typedef struct {
|
|||
} SColumnInfo;
|
||||
|
||||
typedef struct {
|
||||
uint64_t uid;
|
||||
TSKEY key; // last accessed ts, for subscription
|
||||
int64_t uid;
|
||||
TSKEY key; // last accessed ts, for subscription
|
||||
} STableIdInfo;
|
||||
|
||||
typedef struct STimeWindow {
|
||||
|
@ -554,8 +554,8 @@ int32_t tSerializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
|
|||
int32_t tDeserializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
uint64_t uid;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t uid;
|
||||
} SDropDbRsp;
|
||||
|
||||
int32_t tSerializeSDropDbRsp(void* buf, int32_t bufLen, SDropDbRsp* pRsp);
|
||||
|
@ -570,12 +570,12 @@ int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
|
|||
int32_t tDeserializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
uint64_t uid;
|
||||
int32_t vgVersion;
|
||||
int32_t vgNum;
|
||||
int8_t hashMethod;
|
||||
SArray* pVgroupInfos; // Array of SVgroupInfo
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t uid;
|
||||
int32_t vgVersion;
|
||||
int32_t vgNum;
|
||||
int8_t hashMethod;
|
||||
SArray* pVgroupInfos; // Array of SVgroupInfo
|
||||
} SUseDbRsp;
|
||||
|
||||
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
|
||||
|
@ -656,9 +656,9 @@ int32_t tDeserializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp
|
|||
typedef struct {
|
||||
int32_t statusInterval;
|
||||
int64_t checkTime; // 1970-01-01 00:00:00.000
|
||||
char timezone[TSDB_TIMEZONE_LEN]; // tsTimezone
|
||||
char locale[TSDB_LOCALE_LEN]; // tsLocale
|
||||
char charset[TSDB_LOCALE_LEN]; // tsCharset
|
||||
char timezone[TD_TIMEZONE_LEN]; // tsTimezone
|
||||
char locale[TD_LOCALE_LEN]; // tsLocale
|
||||
char charset[TD_LOCALE_LEN]; // tsCharset
|
||||
} SClusterCfg;
|
||||
|
||||
typedef struct {
|
||||
|
@ -725,7 +725,7 @@ typedef struct {
|
|||
int32_t vgId;
|
||||
int32_t dnodeId;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
uint64_t dbUid;
|
||||
int64_t dbUid;
|
||||
int32_t vgVersion;
|
||||
int32_t cacheBlockSize;
|
||||
int32_t totalBlocks;
|
||||
|
@ -753,10 +753,10 @@ int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pR
|
|||
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
int32_t dnodeId;
|
||||
uint64_t dbUid;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int32_t vgId;
|
||||
int32_t dnodeId;
|
||||
int64_t dbUid;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
} SDropVnodeReq, SSyncVnodeReq, SCompactVnodeReq;
|
||||
|
||||
int32_t tSerializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
|
||||
|
@ -796,7 +796,7 @@ typedef struct {
|
|||
char tbName[TSDB_TABLE_NAME_LEN];
|
||||
char stbName[TSDB_TABLE_NAME_LEN];
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
uint64_t dbId;
|
||||
int64_t dbId;
|
||||
int32_t numOfTags;
|
||||
int32_t numOfColumns;
|
||||
int8_t precision;
|
||||
|
@ -1268,7 +1268,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
SMsgHead head;
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
uint64_t tuid;
|
||||
int64_t tuid;
|
||||
int32_t sverson;
|
||||
int32_t execLen;
|
||||
char* executor;
|
||||
|
@ -1279,11 +1279,11 @@ typedef struct {
|
|||
typedef struct {
|
||||
SMsgHead head;
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
uint64_t tuid;
|
||||
int64_t tuid;
|
||||
} SDDropTopicReq;
|
||||
|
||||
typedef struct SVCreateTbReq {
|
||||
uint64_t ver; // use a general definition
|
||||
int64_t ver; // use a general definition
|
||||
char* name;
|
||||
uint32_t ttl;
|
||||
uint32_t keep;
|
||||
|
@ -1314,8 +1314,8 @@ int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
|
|||
void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
uint64_t ver; // use a general definition
|
||||
SArray* pArray;
|
||||
int64_t ver; // use a general definition
|
||||
SArray* pArray;
|
||||
} SVCreateTbBatchReq;
|
||||
|
||||
typedef struct {
|
||||
|
@ -1325,7 +1325,7 @@ int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq);
|
|||
void* tDeserializeSVCreateTbBatchReq(void* buf, SVCreateTbBatchReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
uint64_t ver;
|
||||
int64_t ver;
|
||||
char* name;
|
||||
uint8_t type;
|
||||
tb_uid_t suid;
|
||||
|
@ -1760,35 +1760,19 @@ typedef struct {
|
|||
char cgroup[TSDB_CONSUMER_GROUP_LEN];
|
||||
} SMqOffset;
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
SArray* offsets; // SArray<SMqOffset>
|
||||
} SMqVgOffsets;
|
||||
|
||||
typedef struct {
|
||||
int32_t num;
|
||||
SMqOffset* offsets;
|
||||
} SMqCMResetOffsetReq;
|
||||
} SMqCMCommitOffsetReq;
|
||||
|
||||
typedef struct {
|
||||
int32_t reserved;
|
||||
} SMqCMResetOffsetRsp;
|
||||
|
||||
typedef struct {
|
||||
int64_t leftForVer;
|
||||
SMqVgOffsets offsets;
|
||||
} SMqMVResetOffsetReq;
|
||||
|
||||
typedef struct {
|
||||
int32_t reserved;
|
||||
} SMqMVResetOffsetRsp;
|
||||
} SMqCMCommitOffsetRsp;
|
||||
|
||||
int32_t tEncodeSMqOffset(SCoder* encoder, const SMqOffset* pOffset);
|
||||
int32_t tDecodeSMqOffset(SCoder* decoder, SMqOffset* pOffset);
|
||||
int32_t tEncodeSMqCMResetOffsetReq(SCoder* encoder, const SMqCMResetOffsetReq* pReq);
|
||||
int32_t tDecodeSMqCMResetOffsetReq(SCoder* decoder, SMqCMResetOffsetReq* pReq);
|
||||
int32_t tEncodeSMqMVResetOffsetReq(SCoder* encoder, const SMqMVResetOffsetReq* pReq);
|
||||
int32_t tDecodeSMqMVResetOffsetReq(SCoder* decoder, SMqMVResetOffsetReq* pReq);
|
||||
int32_t tEncodeSMqCMCommitOffsetReq(SCoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
||||
int32_t tDecodeSMqCMCommitOffsetReq(SCoder* decoder, SMqCMCommitOffsetReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
uint32_t nCols;
|
||||
|
@ -1870,7 +1854,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
int64_t consumerId;
|
||||
SSchemaWrapper* schemas;
|
||||
int64_t committedOffset;
|
||||
int64_t reqOffset;
|
||||
int64_t rspOffset;
|
||||
int32_t skipLogNum;
|
||||
|
@ -1881,22 +1864,18 @@ typedef struct {
|
|||
// one req for one vg+topic
|
||||
typedef struct {
|
||||
SMsgHead head;
|
||||
// 0: commit only, current offset
|
||||
// 1: consume only, poll next offset
|
||||
// 2: commit current and consume next offset
|
||||
int32_t reqType;
|
||||
|
||||
int64_t reqId;
|
||||
int64_t consumerId;
|
||||
int64_t blockingTime;
|
||||
char cgroup[TSDB_CONSUMER_GROUP_LEN];
|
||||
|
||||
int64_t offset;
|
||||
int64_t currentOffset;
|
||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||
} SMqConsumeReq;
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
int64_t offset;
|
||||
SEpSet epSet;
|
||||
} SMqSubVgEp;
|
||||
|
||||
|
@ -1917,12 +1896,14 @@ static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) { taos
|
|||
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
|
||||
tlen += taosEncodeFixedI64(buf, pVgEp->offset);
|
||||
tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
|
||||
buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
|
||||
buf = taosDecodeFixedI64(buf, &pVgEp->offset);
|
||||
buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -135,18 +135,19 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_SHOW, "mnode-show", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SHOW_RETRIEVE, "mnode-retrieve", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_STATUS, "mnode-status", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS, "mnode-trans", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TRANS_TIMER, "mnode-trans-tmr", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_KILL_TRANS, "mnode-kill-trans", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TELEM_TIMER, "mnode-telem-tmr", SMTimerReq, SMTimerReq)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GRANT, "mnode-grant", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_AUTH, "mnode-auth", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "mnode-create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "mnode-alter-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_TOPIC, "mnode-drop-topic", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_SUBSCRIBE, "mnode-subscribe", SCMSubscribeReq, SCMSubscribeRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_RESET_OFFSET, "mnode-reset-offset", SMqCMResetOffsetReq, SMqCMResetOffsetRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_SUB_EP, "mnode-get-sub-ep", SMqCMGetSubEpReq, SMqCMGetSubEpRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mnode-mq-timer", SMTimerReq, SMTimerReq)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mnode-mq-tmr", SMTimerReq, SMTimerReq)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_DO_REBALANCE, "mnode-mq-do-rebalance", SMqDoRebalanceMsg, SMqDoRebalanceMsg)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_MQ_COMMIT_OFFSET, "mnode-mq-commit-offset", SMqCMCommitOffsetReq, SMqCMCommitOffsetRsp)
|
||||
|
||||
// Requests handled by VNODE
|
||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||
|
@ -194,4 +195,3 @@ enum {
|
|||
TDMT_MAX
|
||||
#endif
|
||||
};
|
||||
// clang-format on
|
||||
|
|
|
@ -73,9 +73,9 @@ typedef struct STSGroupBlockInfoEx {
|
|||
} STSGroupBlockInfoEx;
|
||||
|
||||
typedef struct STSBuf {
|
||||
FILE* f;
|
||||
char path[PATH_MAX];
|
||||
uint32_t fileSize;
|
||||
TdFilePtr pFile;
|
||||
char path[PATH_MAX];
|
||||
uint32_t fileSize;
|
||||
|
||||
// todo use array
|
||||
STSGroupBlockInfoEx* pData;
|
||||
|
|
|
@ -91,6 +91,8 @@ typedef struct {
|
|||
do { \
|
||||
switch (_type) { \
|
||||
case TSDB_DATA_TYPE_BOOL: \
|
||||
*(bool *)(_v) = (bool)(_data); \
|
||||
break; \
|
||||
case TSDB_DATA_TYPE_TINYINT: \
|
||||
*(int8_t *)(_v) = (int8_t)(_data); \
|
||||
break; \
|
||||
|
@ -104,6 +106,7 @@ typedef struct {
|
|||
*(uint16_t *)(_v) = (uint16_t)(_data); \
|
||||
break; \
|
||||
case TSDB_DATA_TYPE_BIGINT: \
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: \
|
||||
*(int64_t *)(_v) = (int64_t)(_data); \
|
||||
break; \
|
||||
case TSDB_DATA_TYPE_UBIGINT: \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define _TD_DNODE_H_
|
||||
|
||||
#include "tdef.h"
|
||||
#include "tcfg.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -25,26 +26,12 @@ extern "C" {
|
|||
/* ------------------------ TYPES EXPOSED ---------------- */
|
||||
typedef struct SDnode SDnode;
|
||||
|
||||
/* ------------------------ Environment ------------------ */
|
||||
typedef struct {
|
||||
int32_t sver;
|
||||
int32_t numOfCores;
|
||||
int16_t numOfCommitThreads;
|
||||
int8_t enableTelem;
|
||||
char timezone[TSDB_TIMEZONE_LEN];
|
||||
char locale[TSDB_LOCALE_LEN];
|
||||
char charset[TSDB_LOCALE_LEN];
|
||||
char buildinfo[64];
|
||||
char gitinfo[48];
|
||||
} SDnodeEnvCfg;
|
||||
|
||||
/**
|
||||
* @brief Initialize the environment
|
||||
*
|
||||
* @param pOption Option of the environment
|
||||
* @return int32_t 0 for success and -1 for failure
|
||||
*/
|
||||
int32_t dndInit(const SDnodeEnvCfg *pCfg);
|
||||
int32_t dndInit();
|
||||
|
||||
/**
|
||||
* @brief clear the environment
|
||||
|
@ -54,17 +41,15 @@ void dndCleanup();
|
|||
|
||||
/* ------------------------ SDnode ----------------------- */
|
||||
typedef struct {
|
||||
int32_t numOfSupportVnodes;
|
||||
int32_t statusInterval;
|
||||
float numOfThreadsPerCore;
|
||||
float ratioOfQueryCores;
|
||||
int32_t maxShellConns;
|
||||
int32_t shellActivityTimer;
|
||||
uint16_t serverPort;
|
||||
char dataDir[TSDB_FILENAME_LEN];
|
||||
char localEp[TSDB_EP_LEN];
|
||||
char localFqdn[TSDB_FQDN_LEN];
|
||||
char firstEp[TSDB_EP_LEN];
|
||||
int32_t numOfSupportVnodes;
|
||||
uint16_t serverPort;
|
||||
char dataDir[TSDB_FILENAME_LEN];
|
||||
char localEp[TSDB_EP_LEN];
|
||||
char localFqdn[TSDB_FQDN_LEN];
|
||||
char firstEp[TSDB_EP_LEN];
|
||||
char secondEp[TSDB_EP_LEN];
|
||||
SDiskCfg *pDisks;
|
||||
int32_t numOfDisks;
|
||||
} SDnodeObjCfg;
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,25 +44,12 @@ typedef struct SMnodeLoad {
|
|||
int64_t compStorage;
|
||||
} SMnodeLoad;
|
||||
|
||||
typedef struct SMnodeCfg {
|
||||
int32_t sver;
|
||||
int8_t enableTelem;
|
||||
int32_t statusInterval;
|
||||
int32_t shellActivityTimer;
|
||||
char *timezone;
|
||||
char *locale;
|
||||
char *charset;
|
||||
char *buildinfo;
|
||||
char *gitinfo;
|
||||
} SMnodeCfg;
|
||||
|
||||
typedef struct {
|
||||
int32_t dnodeId;
|
||||
int64_t clusterId;
|
||||
int8_t replica;
|
||||
int8_t selfIndex;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
SMnodeCfg cfg;
|
||||
SDnode *pDnode;
|
||||
PutReqToMWriteQFp putReqToMWriteQFp;
|
||||
PutReqToMReadQFp putReqToMReadQFp;
|
||||
|
|
|
@ -113,14 +113,15 @@ typedef enum {
|
|||
SDB_USER = 7,
|
||||
SDB_AUTH = 8,
|
||||
SDB_ACCT = 9,
|
||||
SDB_SUBSCRIBE = 10,
|
||||
SDB_CONSUMER = 11,
|
||||
SDB_TOPIC = 12,
|
||||
SDB_VGROUP = 13,
|
||||
SDB_STB = 14,
|
||||
SDB_DB = 15,
|
||||
SDB_FUNC = 16,
|
||||
SDB_MAX = 17
|
||||
SDB_OFFSET = 10,
|
||||
SDB_SUBSCRIBE = 11,
|
||||
SDB_CONSUMER = 12,
|
||||
SDB_TOPIC = 13,
|
||||
SDB_VGROUP = 14,
|
||||
SDB_STB = 15,
|
||||
SDB_DB = 16,
|
||||
SDB_FUNC = 17,
|
||||
SDB_MAX = 18
|
||||
} ESdbType;
|
||||
|
||||
typedef struct SSdb SSdb;
|
||||
|
|
|
@ -228,6 +228,7 @@ typedef struct SAggFunctionInfo {
|
|||
|
||||
typedef struct SScalarParam {
|
||||
void* data;
|
||||
bool colData;
|
||||
int32_t num;
|
||||
int32_t type;
|
||||
int32_t bytes;
|
||||
|
|
|
@ -61,22 +61,28 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_INTERVAL_WINDOW,
|
||||
QUERY_NODE_NODE_LIST,
|
||||
QUERY_NODE_FILL,
|
||||
QUERY_NODE_COLUMN_REF,
|
||||
QUERY_NODE_RAW_EXPR, // Only be used in parser module.
|
||||
QUERY_NODE_TARGET,
|
||||
|
||||
// Only be used in parser module.
|
||||
QUERY_NODE_RAW_EXPR,
|
||||
QUERY_NODE_TUPLE_DESC,
|
||||
QUERY_NODE_SLOT_DESC,
|
||||
|
||||
// Statement nodes are used in parser and planner module.
|
||||
QUERY_NODE_SET_OPERATOR,
|
||||
QUERY_NODE_SELECT_STMT,
|
||||
QUERY_NODE_SHOW_STMT,
|
||||
|
||||
// logic plan node
|
||||
QUERY_NODE_LOGIC_PLAN_SCAN,
|
||||
QUERY_NODE_LOGIC_PLAN_JOIN,
|
||||
QUERY_NODE_LOGIC_PLAN_FILTER,
|
||||
QUERY_NODE_LOGIC_PLAN_AGG,
|
||||
QUERY_NODE_LOGIC_PLAN_PROJECT
|
||||
QUERY_NODE_LOGIC_PLAN_PROJECT,
|
||||
|
||||
// physical plan node
|
||||
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN,
|
||||
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN,
|
||||
QUERY_NODE_PHYSICAL_PLAN_PROJECT,
|
||||
QUERY_NODE_PHYSICAL_PLAN_JOIN,
|
||||
QUERY_NODE_PHYSICAL_PLAN_AGG
|
||||
} ENodeType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "querynodes.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
typedef struct SLogicNode {
|
||||
ENodeType type;
|
||||
|
@ -31,10 +32,20 @@ typedef struct SLogicNode {
|
|||
struct SLogicNode* pParent;
|
||||
} SLogicNode;
|
||||
|
||||
typedef enum EScanType {
|
||||
SCAN_TYPE_TAG,
|
||||
SCAN_TYPE_TABLE,
|
||||
SCAN_TYPE_STABLE,
|
||||
SCAN_TYPE_STREAM
|
||||
} EScanType;
|
||||
|
||||
typedef struct SScanLogicNode {
|
||||
SLogicNode node;
|
||||
SNodeList* pScanCols;
|
||||
struct STableMeta* pMeta;
|
||||
EScanType scanType;
|
||||
uint8_t scanFlag; // denotes reversed scan of data or not
|
||||
STimeWindow scanRange;
|
||||
} SScanLogicNode;
|
||||
|
||||
typedef struct SJoinLogicNode {
|
||||
|
@ -43,10 +54,6 @@ typedef struct SJoinLogicNode {
|
|||
SNode* pOnConditions;
|
||||
} SJoinLogicNode;
|
||||
|
||||
typedef struct SFilterLogicNode {
|
||||
SLogicNode node;
|
||||
} SFilterLogicNode;
|
||||
|
||||
typedef struct SAggLogicNode {
|
||||
SLogicNode node;
|
||||
SNodeList* pGroupKeys;
|
||||
|
@ -58,6 +65,68 @@ typedef struct SProjectLogicNode {
|
|||
SNodeList* pProjections;
|
||||
} SProjectLogicNode;
|
||||
|
||||
typedef struct SSlotDescNode {
|
||||
ENodeType type;
|
||||
int16_t slotId;
|
||||
SDataType dataType;
|
||||
bool reserve;
|
||||
bool output;
|
||||
} SSlotDescNode;
|
||||
|
||||
typedef struct STupleDescNode {
|
||||
ENodeType type;
|
||||
int16_t tupleId;
|
||||
SNodeList* pSlots;
|
||||
} STupleDescNode;
|
||||
|
||||
typedef struct SPhysiNode {
|
||||
ENodeType type;
|
||||
STupleDescNode outputTuple;
|
||||
SNode* pConditions;
|
||||
SNodeList* pChildren;
|
||||
struct SPhysiNode* pParent;
|
||||
} SPhysiNode;
|
||||
|
||||
typedef struct SScanPhysiNode {
|
||||
SPhysiNode node;
|
||||
SNodeList* pScanCols;
|
||||
uint64_t uid; // unique id of the table
|
||||
int8_t tableType;
|
||||
int32_t order; // scan order: TSDB_ORDER_ASC|TSDB_ORDER_DESC
|
||||
int32_t count; // repeat count
|
||||
int32_t reverse; // reverse scan count
|
||||
} SScanPhysiNode;
|
||||
|
||||
typedef SScanPhysiNode SSystemTableScanPhysiNode;
|
||||
typedef SScanPhysiNode STagScanPhysiNode;
|
||||
|
||||
typedef struct STableScanPhysiNode {
|
||||
SScanPhysiNode scan;
|
||||
uint8_t scanFlag; // denotes reversed scan of data or not
|
||||
STimeWindow scanRange;
|
||||
} STableScanPhysiNode;
|
||||
|
||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||
|
||||
typedef struct SProjectPhysiNode {
|
||||
SPhysiNode node;
|
||||
SNodeList* pProjections;
|
||||
} SProjectPhysiNode;
|
||||
|
||||
typedef struct SJoinPhysiNode {
|
||||
SPhysiNode node;
|
||||
EJoinType joinType;
|
||||
SNode* pOnConditions; // in or out tuple ?
|
||||
SNodeList* pTargets;
|
||||
} SJoinPhysiNode;
|
||||
|
||||
typedef struct SAggPhysiNode {
|
||||
SPhysiNode node;
|
||||
SNodeList* pExprs; // these are expression list of group_by_clause and parameter expression of aggregate function
|
||||
SNodeList* pGroupKeys; // SColumnRefNode list
|
||||
SNodeList* pAggFuncs;
|
||||
} SAggPhysiNode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -58,15 +58,24 @@ typedef struct SColumnNode {
|
|||
char tableAlias[TSDB_TABLE_NAME_LEN];
|
||||
char colName[TSDB_COL_NAME_LEN];
|
||||
SNode* pProjectRef;
|
||||
} SColumnNode;
|
||||
|
||||
typedef struct SColumnRefNode {
|
||||
ENodeType type;
|
||||
SDataType dataType;
|
||||
int16_t tupleId;
|
||||
int16_t slotId;
|
||||
int16_t columnId;
|
||||
} SColumnRefNode;
|
||||
} SColumnNode;
|
||||
|
||||
// typedef struct SColumnRefNode {
|
||||
// ENodeType type;
|
||||
// SDataType dataType;
|
||||
// int16_t tupleId;
|
||||
// int16_t slotId;
|
||||
// int16_t columnId;
|
||||
// } SColumnRefNode;
|
||||
|
||||
typedef struct STargetNode {
|
||||
ENodeType type;
|
||||
int16_t tupleId;
|
||||
int16_t slotId;
|
||||
SNode* pExpr;
|
||||
} STargetNode;
|
||||
|
||||
typedef struct SValueNode {
|
||||
SExprNode node; // QUERY_NODE_VALUE
|
||||
|
@ -81,45 +90,6 @@ typedef struct SValueNode {
|
|||
} datum;
|
||||
} SValueNode;
|
||||
|
||||
typedef enum EOperatorType {
|
||||
// arithmetic operator
|
||||
OP_TYPE_ADD = 1,
|
||||
OP_TYPE_SUB,
|
||||
OP_TYPE_MULTI,
|
||||
OP_TYPE_DIV,
|
||||
OP_TYPE_MOD,
|
||||
|
||||
// bit operator
|
||||
OP_TYPE_BIT_AND,
|
||||
OP_TYPE_BIT_OR,
|
||||
|
||||
// comparison operator
|
||||
OP_TYPE_GREATER_THAN,
|
||||
OP_TYPE_GREATER_EQUAL,
|
||||
OP_TYPE_LOWER_THAN,
|
||||
OP_TYPE_LOWER_EQUAL,
|
||||
OP_TYPE_EQUAL,
|
||||
OP_TYPE_NOT_EQUAL,
|
||||
OP_TYPE_IN,
|
||||
OP_TYPE_NOT_IN,
|
||||
OP_TYPE_LIKE,
|
||||
OP_TYPE_NOT_LIKE,
|
||||
OP_TYPE_MATCH,
|
||||
OP_TYPE_NMATCH,
|
||||
OP_TYPE_IS_NULL,
|
||||
OP_TYPE_IS_NOT_NULL,
|
||||
OP_TYPE_IS_TRUE,
|
||||
OP_TYPE_IS_FALSE,
|
||||
OP_TYPE_IS_UNKNOWN,
|
||||
OP_TYPE_IS_NOT_TRUE,
|
||||
OP_TYPE_IS_NOT_FALSE,
|
||||
OP_TYPE_IS_NOT_UNKNOWN,
|
||||
|
||||
// json operator
|
||||
OP_TYPE_JSON_GET_VALUE,
|
||||
OP_TYPE_JSON_CONTAINS
|
||||
} EOperatorType;
|
||||
|
||||
typedef struct SOperatorNode {
|
||||
SExprNode node; // QUERY_NODE_OPERATOR
|
||||
EOperatorType opType;
|
||||
|
@ -127,11 +97,6 @@ typedef struct SOperatorNode {
|
|||
SNode* pRight;
|
||||
} SOperatorNode;
|
||||
|
||||
typedef enum ELogicConditionType {
|
||||
LOGIC_COND_TYPE_AND,
|
||||
LOGIC_COND_TYPE_OR,
|
||||
LOGIC_COND_TYPE_NOT,
|
||||
} ELogicConditionType;
|
||||
|
||||
typedef struct SLogicConditionNode {
|
||||
SExprNode node; // QUERY_NODE_LOGIC_CONDITION
|
||||
|
@ -141,6 +106,7 @@ typedef struct SLogicConditionNode {
|
|||
|
||||
typedef struct SNodeListNode {
|
||||
ENodeType type; // QUERY_NODE_NODE_LIST
|
||||
SDataType dataType;
|
||||
SNodeList* pNodeList;
|
||||
} SNodeListNode;
|
||||
|
||||
|
@ -306,7 +272,8 @@ bool nodesIsJsonOp(const SOperatorNode* pOp);
|
|||
|
||||
bool nodesIsTimeorderQuery(const SNode* pQuery);
|
||||
bool nodesIsTimelineQuery(const SNode* pQuery);
|
||||
void *nodesGetValueFromNode(SValueNode *pNode);
|
||||
|
||||
void* nodesGetValueFromNode(SValueNode *pNode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -20,6 +20,14 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct SFilterInfo SFilterInfo;
|
||||
typedef int32_t (*filer_get_col_from_id)(void *, int32_t, void **);
|
||||
|
||||
|
||||
enum {
|
||||
FLT_OPTION_NO_REWRITE = 1,
|
||||
FLT_OPTION_TIMESTAMP = 2,
|
||||
FLT_OPTION_NEED_UNIQE = 4,
|
||||
};
|
||||
|
||||
typedef struct SFilterColumnParam{
|
||||
int32_t numOfCols;
|
||||
|
@ -27,8 +35,18 @@ typedef struct SFilterColumnParam{
|
|||
} SFilterColumnParam;
|
||||
|
||||
|
||||
extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options);
|
||||
extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols);
|
||||
extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param);
|
||||
extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param);
|
||||
extern int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win);
|
||||
extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar);
|
||||
extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo);
|
||||
extern void filterFreeInfo(SFilterInfo *info);
|
||||
extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_FILTER_H
|
||||
#endif // TDENGINE_FILTER_H
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef struct SFilterInfo SFilterInfo;
|
|||
int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes);
|
||||
int32_t scalarCalculate(SNode *pNode, SSDataBlock *pSrc, SScalarParam *pDst);
|
||||
int32_t scalarGetOperatorParamNum(EOperatorType type);
|
||||
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
|
||||
|
||||
int32_t vectorGetConvertType(int32_t type1, int32_t type2);
|
||||
int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut);
|
||||
|
|
|
@ -78,12 +78,15 @@ typedef struct SRpcInit {
|
|||
// call back to retrieve the client auth info, for server app only
|
||||
int (*afp)(void *parent, char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
|
||||
// call back to keep conn or not
|
||||
bool (*pfp)(void *parent, tmsg_t msgType);
|
||||
|
||||
void *parent;
|
||||
} SRpcInit;
|
||||
|
||||
int32_t rpcInit();
|
||||
void rpcCleanup();
|
||||
void * rpcOpen(const SRpcInit *pRpc);
|
||||
void *rpcOpen(const SRpcInit *pRpc);
|
||||
void rpcClose(void *);
|
||||
void * rpcMallocCont(int contLen);
|
||||
void rpcFreeCont(void *pCont);
|
||||
|
|
|
@ -120,8 +120,8 @@ typedef struct SWal {
|
|||
int32_t fsyncSeq;
|
||||
// meta
|
||||
SWalVer vers;
|
||||
int64_t writeLogTfd;
|
||||
int64_t writeIdxTfd;
|
||||
TdFilePtr pWriteLogTFile;
|
||||
TdFilePtr pWriteIdxTFile;
|
||||
int32_t writeCur;
|
||||
SArray *fileInfoSet;
|
||||
// status
|
||||
|
@ -138,8 +138,8 @@ typedef struct SWal {
|
|||
|
||||
typedef struct SWalReadHandle {
|
||||
SWal *pWal;
|
||||
int64_t readLogTfd;
|
||||
int64_t readIdxTfd;
|
||||
TdFilePtr pReadLogTFile;
|
||||
TdFilePtr pReadIdxTFile;
|
||||
int64_t curFileFirstVer;
|
||||
int64_t curVersion;
|
||||
int64_t capacity;
|
||||
|
|
|
@ -59,6 +59,7 @@ extern "C" {
|
|||
#include "osEndian.h"
|
||||
#include "osEnv.h"
|
||||
#include "osFile.h"
|
||||
#include "osLocale.h"
|
||||
#include "osLz4.h"
|
||||
#include "osMath.h"
|
||||
#include "osMemory.h"
|
||||
|
@ -73,6 +74,7 @@ extern "C" {
|
|||
#include "osThread.h"
|
||||
#include "osTime.h"
|
||||
#include "osTimer.h"
|
||||
#include "osTimezone.h"
|
||||
|
||||
void osInit();
|
||||
|
||||
|
|
|
@ -191,6 +191,10 @@ extern "C" {
|
|||
#define TD_DIRSEP "/"
|
||||
#endif
|
||||
|
||||
#define TD_LOCALE_LEN 64
|
||||
#define TD_CHARSET_LEN 64
|
||||
#define TD_TIMEZONE_LEN 96
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,8 +23,8 @@ extern "C" {
|
|||
void taosRemoveDir(const char *dirname);
|
||||
int32_t taosDirExist(char *dirname);
|
||||
int32_t taosMkDir(const char *dirname);
|
||||
void taosRemoveOldFiles(char *dirname, int32_t keepDays);
|
||||
int32_t taosExpandDir(char *dirname, char *outname, int32_t maxlen);
|
||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
|
||||
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
|
||||
int32_t taosRealPath(char *dirname, int32_t maxlen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -16,15 +16,37 @@
|
|||
#ifndef _TD_OS_ENV_H_
|
||||
#define _TD_OS_ENV_H_
|
||||
|
||||
#include "osSysinfo.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char tsOsName[];
|
||||
extern char tsOsName[];
|
||||
extern char tsTimezone[];
|
||||
extern char tsCharset[];
|
||||
extern char tsLocale[];
|
||||
extern int8_t tsDaylight;
|
||||
extern bool tsEnableCoreFile;
|
||||
extern int64_t tsPageSize;
|
||||
extern int64_t tsOpenMax;
|
||||
extern int64_t tsStreamMax;
|
||||
extern int32_t tsNumOfCores;
|
||||
extern int32_t tsTotalMemoryMB;
|
||||
|
||||
extern char configDir[];
|
||||
extern char tsDataDir[];
|
||||
extern char tsLogDir[];
|
||||
extern char tsScriptDir[];
|
||||
extern char configDir[];
|
||||
extern char tsTempDir[];
|
||||
|
||||
extern SDiskSpace tsDataSpace;
|
||||
extern SDiskSpace tsLogSpace;
|
||||
extern SDiskSpace tsTempSpace;
|
||||
|
||||
void osInit();
|
||||
void osUpdate();
|
||||
bool osLogSpaceAvailable();
|
||||
void osSetTimezone(const char *timezone);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -22,49 +22,63 @@ extern "C" {
|
|||
|
||||
#include "osSocket.h"
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
typedef int32_t FileFd;
|
||||
#else
|
||||
typedef int32_t FileFd;
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
#define open OPEN_FUNC_TAOS_FORBID
|
||||
#define fopen FOPEN_FUNC_TAOS_FORBID
|
||||
// #define close CLOSE_FUNC_TAOS_FORBID
|
||||
// #define fclose FCLOSE_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
#define FD_INITIALIZER ((int32_t)-1)
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 256
|
||||
#endif
|
||||
|
||||
int32_t taosLockFile(FileFd fd);
|
||||
int32_t taosUnLockFile(FileFd fd);
|
||||
|
||||
int32_t taosUmaskFile(FileFd fd);
|
||||
|
||||
typedef struct TdFile *TdFilePtr;
|
||||
|
||||
#define TD_FILE_CTEATE 0x0001
|
||||
#define TD_FILE_WRITE 0x0002
|
||||
#define TD_FILE_READ 0x0004
|
||||
#define TD_FILE_TRUNC 0x0008
|
||||
#define TD_FILE_APPEND 0x0010
|
||||
#define TD_FILE_TEXT 0x0020
|
||||
#define TD_FILE_AUTO_DEL 0x0040
|
||||
#define TD_FILE_EXCL 0x0080
|
||||
|
||||
int32_t taosLockFile(TdFilePtr pFile);
|
||||
int32_t taosUnLockFile(TdFilePtr pFile);
|
||||
|
||||
int32_t taosUmaskFile(int32_t maskVal);
|
||||
|
||||
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime);
|
||||
int32_t taosFStatFile(FileFd fd, int64_t *size, int32_t *mtime);
|
||||
|
||||
FileFd taosOpenFileWrite(const char *path);
|
||||
FileFd taosOpenFileCreateWrite(const char *path);
|
||||
FileFd taosOpenFileCreateWriteTrunc(const char *path);
|
||||
FileFd taosOpenFileCreateWriteAppend(const char *path);
|
||||
FileFd taosOpenFileRead(const char *path);
|
||||
FileFd taosOpenFileReadWrite(const char *path);
|
||||
|
||||
int64_t taosLSeekFile(FileFd fd, int64_t offset, int32_t whence);
|
||||
int32_t taosFtruncateFile(FileFd fd, int64_t length);
|
||||
int32_t taosFsyncFile(FileFd fd);
|
||||
|
||||
int64_t taosReadFile(FileFd fd, void *buf, int64_t count);
|
||||
int64_t taosWriteFile(FileFd fd, const void *buf, int64_t count);
|
||||
|
||||
void taosCloseFile(FileFd fd);
|
||||
|
||||
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime);
|
||||
|
||||
TdFilePtr taosOpenFile(const char *path,int32_t tdFileOptions);
|
||||
|
||||
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence);
|
||||
int32_t taosFtruncateFile(TdFilePtr pFile, int64_t length);
|
||||
int32_t taosFsyncFile(TdFilePtr pFile);
|
||||
|
||||
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
||||
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
||||
int64_t taosGetLineFile(TdFilePtr pFile, char ** __restrict__ ptrBuf);
|
||||
int32_t taosEOFFile(TdFilePtr pFile);
|
||||
|
||||
int64_t taosCloseFile(TdFilePtr *ppFile);
|
||||
|
||||
int32_t taosRenameFile(const char *oldName, const char *newName);
|
||||
int64_t taosCopyFile(const char *from, const char *to);
|
||||
|
||||
|
||||
void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath);
|
||||
|
||||
int64_t taosSendFile(SocketFd fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size);
|
||||
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size);
|
||||
|
||||
int64_t taosSendFile(SocketFd dfd, FileFd sfd, int64_t *offset, int64_t size);
|
||||
int64_t taosFSendFile(FILE *outfile, FILE *infile, int64_t *offset, int64_t size);
|
||||
void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length);
|
||||
bool taosValidFile(TdFilePtr pFile);
|
||||
|
||||
int taosGetErrorFile(TdFilePtr pFile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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_OS_LOCALE_H_
|
||||
#define _TD_OS_LOCALE_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "osString.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *taosCharsetReplace(char *charsetstr);
|
||||
void taosGetSystemLocale(char *outLocale, char *outCharset);
|
||||
void taosSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_OS_LOCALE_H_*/
|
|
@ -55,7 +55,7 @@ void taosSetMaskSIGPIPE();
|
|||
int32_t taosSetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *optval, int32_t optlen);
|
||||
int32_t taosGetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *optval, int32_t *optlen);
|
||||
|
||||
uint32_t taosInetAddr(char *ipAddr);
|
||||
uint32_t taosInetAddr(const char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt);
|
||||
|
||||
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
|
||||
|
|
|
@ -45,7 +45,6 @@ int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs);
|
|||
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len, int32_t *len);
|
||||
int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes, int8_t ncharSize);
|
||||
bool taosValidateEncodec(const char *encodec);
|
||||
char * taosCharsetReplace(char *charsetstr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -21,18 +21,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#define TSDB_LOCALE_LEN 64
|
||||
#define TSDB_TIMEZONE_LEN 96
|
||||
|
||||
extern int64_t tsPageSize;
|
||||
extern int64_t tsOpenMax;
|
||||
extern int64_t tsStreamMax;
|
||||
extern int32_t tsNumOfCores;
|
||||
extern int32_t tsTotalMemoryMB;
|
||||
extern char tsTimezone[];
|
||||
extern char tsLocale[];
|
||||
extern char tsCharset[]; // default encode string
|
||||
|
||||
typedef struct {
|
||||
int64_t total;
|
||||
|
@ -40,6 +28,11 @@ typedef struct {
|
|||
int64_t avail;
|
||||
} SDiskSize;
|
||||
|
||||
typedef struct {
|
||||
int64_t reserved;
|
||||
SDiskSize size;
|
||||
} SDiskSpace;
|
||||
|
||||
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
|
||||
int32_t taosGetCpuCores();
|
||||
void taosGetSystemInfo();
|
||||
|
@ -51,7 +44,6 @@ void taosGetDisk();
|
|||
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage);
|
||||
bool taosGetProcMemory(float *memoryUsedMB);
|
||||
bool taosGetSysMemory(float *memoryUsedMB);
|
||||
void taosPrintOsInfo();
|
||||
int taosSystem(const char *cmd);
|
||||
void taosKillSystem();
|
||||
int32_t taosGetSystemUUID(char *uid, int32_t uidlen);
|
||||
|
|
|
@ -13,17 +13,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_COMMON_TIMEZONE_H_
|
||||
#define _TD_COMMON_TIMEZONE_H_
|
||||
#ifndef _TD_OS_TIMEZONE_H_
|
||||
#define _TD_OS_TIMEZONE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void tsSetTimeZone();
|
||||
void taosGetSystemTimezone(char *outTimezone);
|
||||
void taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_COMMON_TIMEZONE_H_*/
|
||||
#endif /*_TD_OS_TIMEZONE_H_*/
|
|
@ -16,17 +16,18 @@
|
|||
#ifndef _TD_UTIL_COMPARE_H_
|
||||
#define _TD_UTIL_COMPARE_H_
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#define TSDB_PATTERN_MATCH 0
|
||||
#define TSDB_PATTERN_NOMATCH 1
|
||||
#define TSDB_PATTERN_NOWILDCARDMATCH 2
|
||||
#define TSDB_PATTERN_MATCH 0
|
||||
#define TSDB_PATTERN_NOMATCH 1
|
||||
#define TSDB_PATTERN_NOWILDCARDMATCH 2
|
||||
#define TSDB_PATTERN_STRING_DEFAULT_LEN 100
|
||||
#define TSDB_REGEX_STRING_DEFAULT_LEN 128
|
||||
#define TSDB_REGEX_STRING_DEFAULT_LEN 128
|
||||
|
||||
#define FLT_COMPAR_TOL_FACTOR 4
|
||||
#define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON))
|
||||
|
@ -62,7 +63,6 @@ int32_t setChkNotInBytes8(const void *pLeft, const void *pRight);
|
|||
int32_t compareChkInString(const void *pLeft, const void *pRight);
|
||||
int32_t compareChkNotInString(const void *pLeft, const void *pRight);
|
||||
|
||||
|
||||
int32_t compareInt8Val(const void *pLeft, const void *pRight);
|
||||
int32_t compareInt16Val(const void *pLeft, const void *pRight);
|
||||
int32_t compareInt32Val(const void *pLeft, const void *pRight);
|
||||
|
@ -83,7 +83,6 @@ int32_t compareStrRegexComp(const void *pLeft, const void *pRight);
|
|||
int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight);
|
||||
int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight);
|
||||
|
||||
|
||||
int32_t compareInt8ValDesc(const void *pLeft, const void *pRight);
|
||||
int32_t compareInt16ValDesc(const void *pLeft, const void *pRight);
|
||||
int32_t compareInt32ValDesc(const void *pLeft, const void *pRight);
|
||||
|
@ -102,7 +101,6 @@ int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight);
|
|||
|
||||
__compar_fn_t getComparFunc(int32_t type, int32_t optr);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -13,13 +13,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_COMMON_TAOS_ERROR_H_
|
||||
#define _TD_COMMON_TAOS_ERROR_H_
|
||||
#ifndef _TD_UTIL_TAOS_ERROR_H_
|
||||
#define _TD_UTIL_TAOS_ERROR_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
|
||||
#define TAOS_DEF_ERROR_CODE(mod, code) ((int32_t)((0x80000000 | ((mod)<<16) | (code))))
|
||||
|
||||
#define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code))
|
||||
|
@ -36,28 +38,28 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||
|
||||
// rpc
|
||||
#define TSDB_CODE_RPC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001) //"Action in progress")
|
||||
#define TSDB_CODE_RPC_AUTH_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x0002) //"Authentication required")
|
||||
#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003) //"Authentication failure")
|
||||
#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004) //"Redirect")
|
||||
#define TSDB_CODE_RPC_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005) //"System not ready") // peer is not ready to process data
|
||||
#define TSDB_CODE_RPC_ALREADY_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0006) //"Message already processed")
|
||||
#define TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED TAOS_DEF_ERROR_CODE(0, 0x0007) //"Last session not finished")
|
||||
#define TSDB_CODE_RPC_MISMATCHED_LINK_ID TAOS_DEF_ERROR_CODE(0, 0x0008) //"Mismatched meter id")
|
||||
#define TSDB_CODE_RPC_TOO_SLOW TAOS_DEF_ERROR_CODE(0, 0x0009) //"Processing of request timed out")
|
||||
#define TSDB_CODE_RPC_MAX_SESSIONS TAOS_DEF_ERROR_CODE(0, 0x000A) //"Number of sessions reached limit") // too many sessions
|
||||
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x000B) //"Unable to establish connection")
|
||||
#define TSDB_CODE_RPC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x000C) //"Unexpected generic error in RPC")
|
||||
#define TSDB_CODE_RPC_UNEXPECTED_RESPONSE TAOS_DEF_ERROR_CODE(0, 0x000D) //"Unexpected response")
|
||||
#define TSDB_CODE_RPC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x000E) //"Invalid value")
|
||||
#define TSDB_CODE_RPC_INVALID_TRAN_ID TAOS_DEF_ERROR_CODE(0, 0x000F) //"Invalid transaction id")
|
||||
#define TSDB_CODE_RPC_INVALID_SESSION_ID TAOS_DEF_ERROR_CODE(0, 0x0010) //"Invalid session id")
|
||||
#define TSDB_CODE_RPC_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0011) //"Invalid message type")
|
||||
#define TSDB_CODE_RPC_INVALID_RESPONSE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0012) //"Invalid response type")
|
||||
#define TSDB_CODE_RPC_INVALID_TIME_STAMP TAOS_DEF_ERROR_CODE(0, 0x0013) //"Client and server's time is not synchronized")
|
||||
#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014) //"Database not ready")
|
||||
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0015) //"Unable to resolve FQDN")
|
||||
#define TSDB_CODE_RPC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0016) //"Invalid app version")
|
||||
#define TSDB_CODE_RPC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001)
|
||||
#define TSDB_CODE_RPC_AUTH_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x0002)
|
||||
#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003)
|
||||
#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004)
|
||||
#define TSDB_CODE_RPC_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005)
|
||||
#define TSDB_CODE_RPC_ALREADY_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0006)
|
||||
#define TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED TAOS_DEF_ERROR_CODE(0, 0x0007)
|
||||
#define TSDB_CODE_RPC_MISMATCHED_LINK_ID TAOS_DEF_ERROR_CODE(0, 0x0008)
|
||||
#define TSDB_CODE_RPC_TOO_SLOW TAOS_DEF_ERROR_CODE(0, 0x0009)
|
||||
#define TSDB_CODE_RPC_MAX_SESSIONS TAOS_DEF_ERROR_CODE(0, 0x000A)
|
||||
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x000B)
|
||||
#define TSDB_CODE_RPC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x000C)
|
||||
#define TSDB_CODE_RPC_UNEXPECTED_RESPONSE TAOS_DEF_ERROR_CODE(0, 0x000D)
|
||||
#define TSDB_CODE_RPC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x000E)
|
||||
#define TSDB_CODE_RPC_INVALID_TRAN_ID TAOS_DEF_ERROR_CODE(0, 0x000F)
|
||||
#define TSDB_CODE_RPC_INVALID_SESSION_ID TAOS_DEF_ERROR_CODE(0, 0x0010)
|
||||
#define TSDB_CODE_RPC_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0011)
|
||||
#define TSDB_CODE_RPC_INVALID_RESPONSE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0012)
|
||||
#define TSDB_CODE_RPC_INVALID_TIME_STAMP TAOS_DEF_ERROR_CODE(0, 0x0013)
|
||||
#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014)
|
||||
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0015)
|
||||
#define TSDB_CODE_RPC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0016)
|
||||
|
||||
//common & util
|
||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100)
|
||||
|
@ -71,56 +73,56 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0109)
|
||||
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x010A)
|
||||
#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x010B)
|
||||
|
||||
#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x010C)
|
||||
#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x010D)
|
||||
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0110)
|
||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0111)
|
||||
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0112)
|
||||
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0113)
|
||||
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0114)
|
||||
#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0115)
|
||||
|
||||
#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x0120)
|
||||
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x0121)
|
||||
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x0122)
|
||||
|
||||
//client
|
||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200) //"Invalid Operation")
|
||||
#define TSDB_CODE_TSC_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0201) //"Invalid qhandle")
|
||||
#define TSDB_CODE_TSC_INVALID_TIME_STAMP TAOS_DEF_ERROR_CODE(0, 0x0202) //"Invalid combination of client/service time")
|
||||
#define TSDB_CODE_TSC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x0203) //"Invalid value in client")
|
||||
#define TSDB_CODE_TSC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0204) //"Invalid client version")
|
||||
#define TSDB_CODE_TSC_INVALID_IE TAOS_DEF_ERROR_CODE(0, 0x0205) //"Invalid client ie")
|
||||
#define TSDB_CODE_TSC_INVALID_FQDN TAOS_DEF_ERROR_CODE(0, 0x0206) //"Invalid host name")
|
||||
#define TSDB_CODE_TSC_INVALID_USER_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0207) //"Invalid user name")
|
||||
#define TSDB_CODE_TSC_INVALID_PASS_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0208) //"Invalid password")
|
||||
#define TSDB_CODE_TSC_INVALID_DB_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0209) //"Database name too long")
|
||||
#define TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH TAOS_DEF_ERROR_CODE(0, 0x020A) //"Table name too long")
|
||||
#define TSDB_CODE_TSC_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x020B) //"Invalid connection")
|
||||
#define TSDB_CODE_TSC_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x020C) //"System out of memory")
|
||||
#define TSDB_CODE_TSC_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x020D) //"System out of disk space")
|
||||
#define TSDB_CODE_TSC_QUERY_CACHE_ERASED TAOS_DEF_ERROR_CODE(0, 0x020E) //"Query cache erased")
|
||||
#define TSDB_CODE_TSC_QUERY_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x020F) //"Query terminated")
|
||||
#define TSDB_CODE_TSC_SORTED_RES_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0210) //"Result set too large to be sorted") // too many result for ordered super table projection query
|
||||
#define TSDB_CODE_TSC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0211) //"Application error")
|
||||
#define TSDB_CODE_TSC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0212) //"Action in progress")
|
||||
#define TSDB_CODE_TSC_DISCONNECTED TAOS_DEF_ERROR_CODE(0, 0x0213) //"Disconnected from service")
|
||||
#define TSDB_CODE_TSC_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0214) //"No write permission")
|
||||
#define TSDB_CODE_TSC_CONN_KILLED TAOS_DEF_ERROR_CODE(0, 0x0215) //"Connection killed")
|
||||
#define TSDB_CODE_TSC_SQL_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x0216) //"Syntax error in SQL")
|
||||
#define TSDB_CODE_TSC_DB_NOT_SELECTED TAOS_DEF_ERROR_CODE(0, 0x0217) //"Database not specified or available")
|
||||
#define TSDB_CODE_TSC_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0218) //"Table does not exist")
|
||||
#define TSDB_CODE_TSC_EXCEED_SQL_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0219) //"SQL statement too long check maxSQLLength config")
|
||||
#define TSDB_CODE_TSC_FILE_EMPTY TAOS_DEF_ERROR_CODE(0, 0x021A) //"File is empty")
|
||||
#define TSDB_CODE_TSC_LINE_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x021B) //"Syntax error in Line")
|
||||
#define TSDB_CODE_TSC_NO_META_CACHED TAOS_DEF_ERROR_CODE(0, 0x021C) //"No table meta cached")
|
||||
#define TSDB_CODE_TSC_DUP_COL_NAMES TAOS_DEF_ERROR_CODE(0, 0x021D) //"duplicated column names")
|
||||
#define TSDB_CODE_TSC_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021E) //"Invalid tag length")
|
||||
#define TSDB_CODE_TSC_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021F) //"Invalid column length")
|
||||
#define TSDB_CODE_TSC_DUP_TAG_NAMES TAOS_DEF_ERROR_CODE(0, 0x0220) //"duplicated tag names")
|
||||
#define TSDB_CODE_TSC_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x0221) //"Invalid JSON format")
|
||||
#define TSDB_CODE_TSC_INVALID_JSON_TYPE TAOS_DEF_ERROR_CODE(0, 0x0222) //"Invalid JSON data type")
|
||||
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0223) //"Value out of range")
|
||||
#define TSDB_CODE_TSC_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0X0224) //"Invalid tsc input")
|
||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||
#define TSDB_CODE_TSC_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0201)
|
||||
#define TSDB_CODE_TSC_INVALID_TIME_STAMP TAOS_DEF_ERROR_CODE(0, 0x0202)
|
||||
#define TSDB_CODE_TSC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x0203)
|
||||
#define TSDB_CODE_TSC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0204)
|
||||
#define TSDB_CODE_TSC_INVALID_IE TAOS_DEF_ERROR_CODE(0, 0x0205)
|
||||
#define TSDB_CODE_TSC_INVALID_FQDN TAOS_DEF_ERROR_CODE(0, 0x0206)
|
||||
#define TSDB_CODE_TSC_INVALID_USER_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0207)
|
||||
#define TSDB_CODE_TSC_INVALID_PASS_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0208)
|
||||
#define TSDB_CODE_TSC_INVALID_DB_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0209)
|
||||
#define TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH TAOS_DEF_ERROR_CODE(0, 0x020A)
|
||||
#define TSDB_CODE_TSC_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x020B)
|
||||
#define TSDB_CODE_TSC_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x020C)
|
||||
#define TSDB_CODE_TSC_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x020D)
|
||||
#define TSDB_CODE_TSC_QUERY_CACHE_ERASED TAOS_DEF_ERROR_CODE(0, 0x020E)
|
||||
#define TSDB_CODE_TSC_QUERY_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x020F)
|
||||
#define TSDB_CODE_TSC_SORTED_RES_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0210)
|
||||
#define TSDB_CODE_TSC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0211)
|
||||
#define TSDB_CODE_TSC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0212)
|
||||
#define TSDB_CODE_TSC_DISCONNECTED TAOS_DEF_ERROR_CODE(0, 0x0213)
|
||||
#define TSDB_CODE_TSC_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0214)
|
||||
#define TSDB_CODE_TSC_CONN_KILLED TAOS_DEF_ERROR_CODE(0, 0x0215)
|
||||
#define TSDB_CODE_TSC_SQL_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x0216)
|
||||
#define TSDB_CODE_TSC_DB_NOT_SELECTED TAOS_DEF_ERROR_CODE(0, 0x0217)
|
||||
#define TSDB_CODE_TSC_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0218)
|
||||
#define TSDB_CODE_TSC_EXCEED_SQL_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0219)
|
||||
#define TSDB_CODE_TSC_FILE_EMPTY TAOS_DEF_ERROR_CODE(0, 0x021A)
|
||||
#define TSDB_CODE_TSC_LINE_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x021B)
|
||||
#define TSDB_CODE_TSC_NO_META_CACHED TAOS_DEF_ERROR_CODE(0, 0x021C)
|
||||
#define TSDB_CODE_TSC_DUP_COL_NAMES TAOS_DEF_ERROR_CODE(0, 0x021D)
|
||||
#define TSDB_CODE_TSC_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021E)
|
||||
#define TSDB_CODE_TSC_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021F)
|
||||
#define TSDB_CODE_TSC_DUP_TAG_NAMES TAOS_DEF_ERROR_CODE(0, 0x0220)
|
||||
#define TSDB_CODE_TSC_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x0221)
|
||||
#define TSDB_CODE_TSC_INVALID_JSON_TYPE TAOS_DEF_ERROR_CODE(0, 0x0222)
|
||||
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0223)
|
||||
#define TSDB_CODE_TSC_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0X0224)
|
||||
|
||||
// mnode-common
|
||||
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
|
||||
|
@ -260,6 +262,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_CONSUMER_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E7)
|
||||
#define TSDB_CODE_MND_UNSUPPORTED_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03E8)
|
||||
#define TSDB_CODE_MND_SUBSCRIBE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E9)
|
||||
#define TSDB_CODE_MND_OFFSET_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03EA)
|
||||
#define TSDB_CODE_MND_MQ_PLACEHOLDER TAOS_DEF_ERROR_CODE(0, 0x03F0)
|
||||
|
||||
// dnode
|
||||
|
@ -296,174 +299,174 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_DND_VNODE_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x0465)
|
||||
|
||||
// vnode
|
||||
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) //"Action in progress")
|
||||
#define TSDB_CODE_VND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0501) //"Message not processed")
|
||||
#define TSDB_CODE_VND_ACTION_NEED_REPROCESSED TAOS_DEF_ERROR_CODE(0, 0x0502) //"Action need to be reprocessed")
|
||||
#define TSDB_CODE_VND_INVALID_VGROUP_ID TAOS_DEF_ERROR_CODE(0, 0x0503) //"Invalid Vgroup ID")
|
||||
#define TSDB_CODE_VND_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0504) //"Vnode initialization failed")
|
||||
#define TSDB_CODE_VND_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0505) //"System out of disk space")
|
||||
#define TSDB_CODE_VND_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0506) //"No write permission for disk files")
|
||||
#define TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR TAOS_DEF_ERROR_CODE(0, 0x0507) //"Missing data file")
|
||||
#define TSDB_CODE_VND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0508) //"Out of memory")
|
||||
#define TSDB_CODE_VND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0509) //"Unexpected generic error in vnode")
|
||||
#define TSDB_CODE_VND_INVALID_CFG_FILE TAOS_DEF_ERROR_CODE(0, 0x050A) //"Invalid config file)
|
||||
#define TSDB_CODE_VND_INVALID_TERM_FILE TAOS_DEF_ERROR_CODE(0, 0x050B) //"Invalid term file")
|
||||
#define TSDB_CODE_VND_IS_FLOWCTRL TAOS_DEF_ERROR_CODE(0, 0x050C) //"Database memory is full")
|
||||
#define TSDB_CODE_VND_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x050D) //"Database is dropping")
|
||||
#define TSDB_CODE_VND_IS_UPDATING TAOS_DEF_ERROR_CODE(0, 0x050E) //"Database is updating")
|
||||
#define TSDB_CODE_VND_IS_CLOSING TAOS_DEF_ERROR_CODE(0, 0x0510) //"Database is closing")
|
||||
#define TSDB_CODE_VND_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0511) //"Database suspended")
|
||||
#define TSDB_CODE_VND_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0512) //"Database write operation denied")
|
||||
#define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513) //"Database is syncing")
|
||||
#define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514) //"Invalid tsdb state")
|
||||
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0515) // "Table not exists")
|
||||
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
|
||||
#define TSDB_CODE_VND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0501)
|
||||
#define TSDB_CODE_VND_ACTION_NEED_REPROCESSED TAOS_DEF_ERROR_CODE(0, 0x0502)
|
||||
#define TSDB_CODE_VND_INVALID_VGROUP_ID TAOS_DEF_ERROR_CODE(0, 0x0503)
|
||||
#define TSDB_CODE_VND_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0504)
|
||||
#define TSDB_CODE_VND_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0505)
|
||||
#define TSDB_CODE_VND_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0506)
|
||||
#define TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR TAOS_DEF_ERROR_CODE(0, 0x0507)
|
||||
#define TSDB_CODE_VND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0508)
|
||||
#define TSDB_CODE_VND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0509)
|
||||
#define TSDB_CODE_VND_INVALID_CFG_FILE TAOS_DEF_ERROR_CODE(0, 0x050A)
|
||||
#define TSDB_CODE_VND_INVALID_TERM_FILE TAOS_DEF_ERROR_CODE(0, 0x050B)
|
||||
#define TSDB_CODE_VND_IS_FLOWCTRL TAOS_DEF_ERROR_CODE(0, 0x050C)
|
||||
#define TSDB_CODE_VND_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x050D)
|
||||
#define TSDB_CODE_VND_IS_UPDATING TAOS_DEF_ERROR_CODE(0, 0x050E)
|
||||
#define TSDB_CODE_VND_IS_CLOSING TAOS_DEF_ERROR_CODE(0, 0x0510)
|
||||
#define TSDB_CODE_VND_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0511)
|
||||
#define TSDB_CODE_VND_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0512)
|
||||
#define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513)
|
||||
#define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514)
|
||||
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0515)
|
||||
|
||||
// tsdb
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600) //"Invalid table ID")
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0601) //"Invalid table type")
|
||||
#define TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0602) //"Invalid table schema version")
|
||||
#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603) //"Table already exists")
|
||||
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604) //"Invalid configuration")
|
||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605) //"Tsdb init failed")
|
||||
#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0606) //"No diskspace for tsdb")
|
||||
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607) //"No permission for disk files")
|
||||
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608) //"Data file(s) corrupted")
|
||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609) //"Out of memory")
|
||||
#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A) //"Tag too old")
|
||||
#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B) //"Timestamp data out of range")
|
||||
#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C) //"Submit message is messed up")
|
||||
#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x060D) //"Invalid operation")
|
||||
#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x060E) //"Invalid creation of table")
|
||||
#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x060F) //"No table data in memory skiplist")
|
||||
#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0610) //"File already exists")
|
||||
#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0611) //"Need to reconfigure table")
|
||||
#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0612) //"Invalid information to create table")
|
||||
#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0613) //"No available disk")
|
||||
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614) //"TSDB messed message")
|
||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) //"TSDB invalid tag value")
|
||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) //"TSDB no cache last row data")
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0601)
|
||||
#define TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0602)
|
||||
#define TSDB_CODE_TDB_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0603)
|
||||
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604)
|
||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605)
|
||||
#define TSDB_CODE_TDB_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0606)
|
||||
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607)
|
||||
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609)
|
||||
#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A)
|
||||
#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B)
|
||||
#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C)
|
||||
#define TSDB_CODE_TDB_INVALID_ACTION TAOS_DEF_ERROR_CODE(0, 0x060D)
|
||||
#define TSDB_CODE_TDB_INVALID_CREATE_TB_MSG TAOS_DEF_ERROR_CODE(0, 0x060E)
|
||||
#define TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM TAOS_DEF_ERROR_CODE(0, 0x060F)
|
||||
#define TSDB_CODE_TDB_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0610)
|
||||
#define TSDB_CODE_TDB_TABLE_RECONFIGURE TAOS_DEF_ERROR_CODE(0, 0x0611)
|
||||
#define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0612)
|
||||
#define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0613)
|
||||
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
|
||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
||||
|
||||
// query
|
||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) //"Invalid handle")
|
||||
#define TSDB_CODE_QRY_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0701) //"Invalid message") // failed to validate the sql expression msg by vnode
|
||||
#define TSDB_CODE_QRY_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0702) //"No diskspace for query")
|
||||
#define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703) //"System out of memory")
|
||||
#define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704) //"Unexpected generic error in query")
|
||||
#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705) //"Duplicated join key")
|
||||
#define TSDB_CODE_QRY_EXCEED_TAGS_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0706) //"Tag conditon too many")
|
||||
#define TSDB_CODE_QRY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0707) //"Query not ready")
|
||||
#define TSDB_CODE_QRY_HAS_RSP TAOS_DEF_ERROR_CODE(0, 0x0708) //"Query should response")
|
||||
#define TSDB_CODE_QRY_IN_EXEC TAOS_DEF_ERROR_CODE(0, 0x0709) //"Multiple retrieval of this query")
|
||||
#define TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW TAOS_DEF_ERROR_CODE(0, 0x070A) //"Too many time window in query")
|
||||
#define TSDB_CODE_QRY_NOT_ENOUGH_BUFFER TAOS_DEF_ERROR_CODE(0, 0x070B) //"Query buffer limit has reached")
|
||||
#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C) //"File inconsistency in replica")
|
||||
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D) //"invalid time condition")
|
||||
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E) //"System error")
|
||||
#define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F) //"invalid input")
|
||||
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0710) //"Scheduler not exist")
|
||||
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0711) //"Task not exist")
|
||||
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0712) //"Task already exist")
|
||||
#define TSDB_CODE_QRY_TASK_CTX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0713) //"Task context not exist")
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x0714) //"Task cancelled")
|
||||
#define TSDB_CODE_QRY_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x0715) //"Task dropped")
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLING TAOS_DEF_ERROR_CODE(0, 0x0716) //"Task cancelling")
|
||||
#define TSDB_CODE_QRY_TASK_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0717) //"Task dropping")
|
||||
#define TSDB_CODE_QRY_DUPLICATTED_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0718) //"Duplicatted operation")
|
||||
#define TSDB_CODE_QRY_TASK_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x0719) //"Task message error")
|
||||
#define TSDB_CODE_QRY_JOB_FREED TAOS_DEF_ERROR_CODE(0, 0x071A) //"Job freed")
|
||||
#define TSDB_CODE_QRY_TASK_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x071B) //"Task status error")
|
||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||
#define TSDB_CODE_QRY_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0701)
|
||||
#define TSDB_CODE_QRY_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0702)
|
||||
#define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703)
|
||||
#define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704)
|
||||
#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705)
|
||||
#define TSDB_CODE_QRY_EXCEED_TAGS_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0706)
|
||||
#define TSDB_CODE_QRY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0707)
|
||||
#define TSDB_CODE_QRY_HAS_RSP TAOS_DEF_ERROR_CODE(0, 0x0708)
|
||||
#define TSDB_CODE_QRY_IN_EXEC TAOS_DEF_ERROR_CODE(0, 0x0709)
|
||||
#define TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW TAOS_DEF_ERROR_CODE(0, 0x070A)
|
||||
#define TSDB_CODE_QRY_NOT_ENOUGH_BUFFER TAOS_DEF_ERROR_CODE(0, 0x070B)
|
||||
#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C)
|
||||
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D)
|
||||
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E)
|
||||
#define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F)
|
||||
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0710)
|
||||
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0711)
|
||||
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0712)
|
||||
#define TSDB_CODE_QRY_TASK_CTX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0713)
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x0714)
|
||||
#define TSDB_CODE_QRY_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x0715)
|
||||
#define TSDB_CODE_QRY_TASK_CANCELLING TAOS_DEF_ERROR_CODE(0, 0x0716)
|
||||
#define TSDB_CODE_QRY_TASK_DROPPING TAOS_DEF_ERROR_CODE(0, 0x0717)
|
||||
#define TSDB_CODE_QRY_DUPLICATTED_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0718)
|
||||
#define TSDB_CODE_QRY_TASK_MSG_ERROR TAOS_DEF_ERROR_CODE(0, 0x0719)
|
||||
#define TSDB_CODE_QRY_JOB_FREED TAOS_DEF_ERROR_CODE(0, 0x071A)
|
||||
#define TSDB_CODE_QRY_TASK_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x071B)
|
||||
|
||||
// grant
|
||||
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) //"License expired")
|
||||
#define TSDB_CODE_GRANT_DNODE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0801) //"DNode creation limited by licence")
|
||||
#define TSDB_CODE_GRANT_ACCT_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0802) //"Account creation limited by license")
|
||||
#define TSDB_CODE_GRANT_TIMESERIES_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0803) //"Table creation limited by license")
|
||||
#define TSDB_CODE_GRANT_DB_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0804) //"DB creation limited by license")
|
||||
#define TSDB_CODE_GRANT_USER_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0805) //"User creation limited by license")
|
||||
#define TSDB_CODE_GRANT_CONN_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0806) //"Conn creation limited by license")
|
||||
#define TSDB_CODE_GRANT_STREAM_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0807) //"Stream creation limited by license")
|
||||
#define TSDB_CODE_GRANT_SPEED_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0808) //"Write speed limited by license")
|
||||
#define TSDB_CODE_GRANT_STORAGE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0809) //"Storage capacity limited by license")
|
||||
#define TSDB_CODE_GRANT_QUERYTIME_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080A) //"Query time limited by license")
|
||||
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B) //"CPU cores limited by license")
|
||||
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800)
|
||||
#define TSDB_CODE_GRANT_DNODE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0801)
|
||||
#define TSDB_CODE_GRANT_ACCT_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0802)
|
||||
#define TSDB_CODE_GRANT_TIMESERIES_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0803)
|
||||
#define TSDB_CODE_GRANT_DB_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0804)
|
||||
#define TSDB_CODE_GRANT_USER_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0805)
|
||||
#define TSDB_CODE_GRANT_CONN_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0806)
|
||||
#define TSDB_CODE_GRANT_STREAM_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0807)
|
||||
#define TSDB_CODE_GRANT_SPEED_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0808)
|
||||
#define TSDB_CODE_GRANT_STORAGE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0809)
|
||||
#define TSDB_CODE_GRANT_QUERYTIME_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080A)
|
||||
#define TSDB_CODE_GRANT_CPU_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080B)
|
||||
|
||||
// sync
|
||||
#define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) //"Invalid Sync Configuration")
|
||||
#define TSDB_CODE_SYN_NOT_ENABLED TAOS_DEF_ERROR_CODE(0, 0x0901) //"Sync module not enabled")
|
||||
#define TSDB_CODE_SYN_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0902) //"Invalid Sync version")
|
||||
#define TSDB_CODE_SYN_CONFIRM_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0903) //"Sync confirm expired")
|
||||
#define TSDB_CODE_SYN_TOO_MANY_FWDINFO TAOS_DEF_ERROR_CODE(0, 0x0904) //"Too many sync fwd infos")
|
||||
#define TSDB_CODE_SYN_MISMATCHED_PROTOCOL TAOS_DEF_ERROR_CODE(0, 0x0905) //"Mismatched protocol")
|
||||
#define TSDB_CODE_SYN_MISMATCHED_CLUSTERID TAOS_DEF_ERROR_CODE(0, 0x0906) //"Mismatched clusterId")
|
||||
#define TSDB_CODE_SYN_MISMATCHED_SIGNATURE TAOS_DEF_ERROR_CODE(0, 0x0907) //"Mismatched signature")
|
||||
#define TSDB_CODE_SYN_INVALID_CHECKSUM TAOS_DEF_ERROR_CODE(0, 0x0908) //"Invalid msg checksum")
|
||||
#define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909) //"Invalid msg length")
|
||||
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A) //"Invalid msg type")
|
||||
#define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900)
|
||||
#define TSDB_CODE_SYN_NOT_ENABLED TAOS_DEF_ERROR_CODE(0, 0x0901)
|
||||
#define TSDB_CODE_SYN_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0902)
|
||||
#define TSDB_CODE_SYN_CONFIRM_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0903)
|
||||
#define TSDB_CODE_SYN_TOO_MANY_FWDINFO TAOS_DEF_ERROR_CODE(0, 0x0904)
|
||||
#define TSDB_CODE_SYN_MISMATCHED_PROTOCOL TAOS_DEF_ERROR_CODE(0, 0x0905)
|
||||
#define TSDB_CODE_SYN_MISMATCHED_CLUSTERID TAOS_DEF_ERROR_CODE(0, 0x0906)
|
||||
#define TSDB_CODE_SYN_MISMATCHED_SIGNATURE TAOS_DEF_ERROR_CODE(0, 0x0907)
|
||||
#define TSDB_CODE_SYN_INVALID_CHECKSUM TAOS_DEF_ERROR_CODE(0, 0x0908)
|
||||
#define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909)
|
||||
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A)
|
||||
|
||||
// tq
|
||||
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00) //"Invalid configuration")
|
||||
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01) //"Tq init failed")
|
||||
#define TSDB_CODE_TQ_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0A02) //"No diskspace for tq")
|
||||
#define TSDB_CODE_TQ_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0A03) //"No permission for disk files")
|
||||
#define TSDB_CODE_TQ_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04) //"Data file(s) corrupted")
|
||||
#define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05) //"Out of memory")
|
||||
#define TSDB_CODE_TQ_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0A06) //"File already exists")
|
||||
#define TSDB_CODE_TQ_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0A07) //"Failed to create dir")
|
||||
#define TSDB_CODE_TQ_META_NO_SUCH_KEY TAOS_DEF_ERROR_CODE(0, 0x0A08) //"Target key not found")
|
||||
#define TSDB_CODE_TQ_META_KEY_NOT_IN_TXN TAOS_DEF_ERROR_CODE(0, 0x0A09) //"Target key not in transaction")
|
||||
#define TSDB_CODE_TQ_META_KEY_DUP_IN_TXN TAOS_DEF_ERROR_CODE(0, 0x0A0A) //"Target key duplicated in transaction")
|
||||
#define TSDB_CODE_TQ_GROUP_NOT_SET TAOS_DEF_ERROR_CODE(0, 0x0A0B) //"Group of corresponding client is not set by mnode")
|
||||
#define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00)
|
||||
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01)
|
||||
#define TSDB_CODE_TQ_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0A02)
|
||||
#define TSDB_CODE_TQ_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0A03)
|
||||
#define TSDB_CODE_TQ_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04)
|
||||
#define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
||||
#define TSDB_CODE_TQ_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0A06)
|
||||
#define TSDB_CODE_TQ_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0A07)
|
||||
#define TSDB_CODE_TQ_META_NO_SUCH_KEY TAOS_DEF_ERROR_CODE(0, 0x0A08)
|
||||
#define TSDB_CODE_TQ_META_KEY_NOT_IN_TXN TAOS_DEF_ERROR_CODE(0, 0x0A09)
|
||||
#define TSDB_CODE_TQ_META_KEY_DUP_IN_TXN TAOS_DEF_ERROR_CODE(0, 0x0A0A)
|
||||
#define TSDB_CODE_TQ_GROUP_NOT_SET TAOS_DEF_ERROR_CODE(0, 0x0A0B)
|
||||
|
||||
// wal
|
||||
#define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000) //"Unexpected generic error in wal")
|
||||
#define TSDB_CODE_WAL_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x1001) //"WAL file is corrupted")
|
||||
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002) //"WAL size exceeds limit")
|
||||
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003) //"WAL invalid version")
|
||||
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004) //"WAL out of memory")
|
||||
#define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000)
|
||||
#define TSDB_CODE_WAL_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x1001)
|
||||
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002)
|
||||
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003)
|
||||
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
|
||||
|
||||
// tfs
|
||||
#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x2200) //"tfs out of memory")
|
||||
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201) //"tfs invalid mount config")
|
||||
#define TSDB_CODE_FS_TOO_MANY_MOUNT TAOS_DEF_ERROR_CODE(0, 0x2202) //"tfs too many mount")
|
||||
#define TSDB_CODE_FS_DUP_PRIMARY TAOS_DEF_ERROR_CODE(0, 0x2203) //"tfs duplicate primary mount")
|
||||
#define TSDB_CODE_FS_NO_PRIMARY_DISK TAOS_DEF_ERROR_CODE(0, 0x2204) //"tfs no primary mount")
|
||||
#define TSDB_CODE_FS_NO_MOUNT_AT_TIER TAOS_DEF_ERROR_CODE(0, 0x2205) //"tfs no mount at tier")
|
||||
#define TSDB_CODE_FS_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x2206) //"tfs file already exists")
|
||||
#define TSDB_CODE_FS_INVLD_LEVEL TAOS_DEF_ERROR_CODE(0, 0x2207) //"tfs invalid level")
|
||||
#define TSDB_CODE_FS_NO_VALID_DISK TAOS_DEF_ERROR_CODE(0, 0x2208) //"tfs no valid disk")
|
||||
#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x2200)
|
||||
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
|
||||
#define TSDB_CODE_FS_TOO_MANY_MOUNT TAOS_DEF_ERROR_CODE(0, 0x2202)
|
||||
#define TSDB_CODE_FS_DUP_PRIMARY TAOS_DEF_ERROR_CODE(0, 0x2203)
|
||||
#define TSDB_CODE_FS_NO_PRIMARY_DISK TAOS_DEF_ERROR_CODE(0, 0x2204)
|
||||
#define TSDB_CODE_FS_NO_MOUNT_AT_TIER TAOS_DEF_ERROR_CODE(0, 0x2205)
|
||||
#define TSDB_CODE_FS_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x2206)
|
||||
#define TSDB_CODE_FS_INVLD_LEVEL TAOS_DEF_ERROR_CODE(0, 0x2207)
|
||||
#define TSDB_CODE_FS_NO_VALID_DISK TAOS_DEF_ERROR_CODE(0, 0x2208)
|
||||
|
||||
// monitor
|
||||
#define TSDB_CODE_MON_CONNECTION_INVALID TAOS_DEF_ERROR_CODE(0, 0x2300) //"monitor invalid monitor db connection")
|
||||
#define TSDB_CODE_MON_CONNECTION_INVALID TAOS_DEF_ERROR_CODE(0, 0x2300)
|
||||
|
||||
// catalog
|
||||
#define TSDB_CODE_CTG_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2400) //catalog interval error
|
||||
#define TSDB_CODE_CTG_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x2401) //invalid catalog input parameters
|
||||
#define TSDB_CODE_CTG_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x2402) //catalog is not ready
|
||||
#define TSDB_CODE_CTG_MEM_ERROR TAOS_DEF_ERROR_CODE(0, 0x2403) //catalog memory error
|
||||
#define TSDB_CODE_CTG_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2404) //catalog system error
|
||||
#define TSDB_CODE_CTG_DB_DROPPED TAOS_DEF_ERROR_CODE(0, 0x2405) //Database is dropped
|
||||
#define TSDB_CODE_CTG_OUT_OF_SERVICE TAOS_DEF_ERROR_CODE(0, 0x2406) //catalog is out of service
|
||||
#define TSDB_CODE_CTG_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2400)
|
||||
#define TSDB_CODE_CTG_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x2401)
|
||||
#define TSDB_CODE_CTG_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x2402)
|
||||
#define TSDB_CODE_CTG_MEM_ERROR TAOS_DEF_ERROR_CODE(0, 0x2403)
|
||||
#define TSDB_CODE_CTG_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2404)
|
||||
#define TSDB_CODE_CTG_DB_DROPPED TAOS_DEF_ERROR_CODE(0, 0x2405)
|
||||
#define TSDB_CODE_CTG_OUT_OF_SERVICE TAOS_DEF_ERROR_CODE(0, 0x2406)
|
||||
|
||||
//scheduler
|
||||
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501) //scheduler status error
|
||||
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502) //scheduler internal error
|
||||
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501)
|
||||
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502)
|
||||
|
||||
//parser
|
||||
#define TSDB_CODE_PAR_INVALID_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2601) //Invalid column name
|
||||
#define TSDB_CODE_PAR_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2602) //Table does not exist
|
||||
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603) //Column ambiguously defined
|
||||
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604) //Invalid value type
|
||||
#define TSDB_CODE_PAR_INVALID_FUNTION TAOS_DEF_ERROR_CODE(0, 0x2605) //Invalid function name
|
||||
#define TSDB_CODE_PAR_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2606) //Invalid number of arguments
|
||||
#define TSDB_CODE_PAR_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2607) //Inconsistent datatypes
|
||||
#define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608) //There mustn't be aggregation
|
||||
#define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609) //ORDER BY item must be the number of a SELECT-list expression
|
||||
#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A) //Not a GROUP BY expression
|
||||
#define TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260B) //Not SELECTed expression
|
||||
#define TSDB_CODE_PAR_NOT_SINGLE_GROUP TAOS_DEF_ERROR_CODE(0, 0x260C) //Not a single-group group function
|
||||
#define TSDB_CODE_PAR_INVALID_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2601)
|
||||
#define TSDB_CODE_PAR_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2602)
|
||||
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603)
|
||||
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604)
|
||||
#define TSDB_CODE_PAR_INVALID_FUNTION TAOS_DEF_ERROR_CODE(0, 0x2605)
|
||||
#define TSDB_CODE_PAR_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2606)
|
||||
#define TSDB_CODE_PAR_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2607)
|
||||
#define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608)
|
||||
#define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609)
|
||||
#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A)
|
||||
#define TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260B)
|
||||
#define TSDB_CODE_PAR_NOT_SINGLE_GROUP TAOS_DEF_ERROR_CODE(0, 0x260C)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_COMMON_TAOS_ERROR_H_*/
|
||||
#endif /*_TD_UTIL_TAOS_ERROR_H_*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
|
@ -13,85 +14,98 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_UTIL_CONFIG_H
|
||||
#define _TD_UTIL_CONFIG_H
|
||||
#ifndef _TD_CONFIG_H_
|
||||
#define _TD_CONFIG_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tarray.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TSDB_CFG_MAX_NUM 115
|
||||
#define TSDB_CFG_PRINT_LEN 23
|
||||
#define TSDB_CFG_OPTION_LEN 24
|
||||
#define TSDB_CFG_VALUE_LEN 41
|
||||
#define CFG_NAME_MAX_LEN 128
|
||||
|
||||
#define TSDB_CFG_CTYPE_B_CONFIG 1U // can be configured from file
|
||||
#define TSDB_CFG_CTYPE_B_SHOW 2U // can displayed by "show configs" commands
|
||||
#define TSDB_CFG_CTYPE_B_LOG 4U // is a log type configuration
|
||||
#define TSDB_CFG_CTYPE_B_CLIENT 8U // can be displayed in the client log
|
||||
#define TSDB_CFG_CTYPE_B_OPTION 16U // can be configured by taos_options function
|
||||
#define TSDB_CFG_CTYPE_B_NOT_PRINT 32U // such as password
|
||||
typedef enum {
|
||||
CFG_STYPE_DEFAULT,
|
||||
CFG_STYPE_CFG_FILE,
|
||||
CFG_STYPE_ENV_FILE,
|
||||
CFG_STYPE_ENV_VAR,
|
||||
CFG_STYPE_APOLLO_URL,
|
||||
CFG_STYPE_ARG_LIST,
|
||||
} ECfgSrcType;
|
||||
|
||||
#define MAX_FLOAT 100000
|
||||
#define MIN_FLOAT 0
|
||||
typedef enum {
|
||||
CFG_DTYPE_NONE,
|
||||
CFG_DTYPE_BOOL,
|
||||
CFG_DTYPE_INT32,
|
||||
CFG_DTYPE_INT64,
|
||||
CFG_DTYPE_FLOAT,
|
||||
CFG_DTYPE_STRING,
|
||||
CFG_DTYPE_DIR,
|
||||
CFG_DTYPE_LOCALE,
|
||||
CFG_DTYPE_CHARSET,
|
||||
CFG_DTYPE_TIMEZONE
|
||||
} ECfgDataType;
|
||||
|
||||
enum {
|
||||
TAOS_CFG_CSTATUS_NONE, // not configured
|
||||
TAOS_CFG_CSTATUS_DEFAULT, // use system default value
|
||||
TAOS_CFG_CSTATUS_FILE, // configured from file
|
||||
TAOS_CFG_CSTATUS_OPTION, // configured by taos_options function
|
||||
TAOS_CFG_CSTATUS_ARG, // configured by program argument
|
||||
};
|
||||
|
||||
enum {
|
||||
TAOS_CFG_VTYPE_INT8,
|
||||
TAOS_CFG_VTYPE_INT16,
|
||||
TAOS_CFG_VTYPE_INT32,
|
||||
TAOS_CFG_VTYPE_UINT16,
|
||||
TAOS_CFG_VTYPE_FLOAT,
|
||||
TAOS_CFG_VTYPE_STRING,
|
||||
TAOS_CFG_VTYPE_IPSTR,
|
||||
TAOS_CFG_VTYPE_DIRECTORY,
|
||||
TAOS_CFG_VTYPE_DATA_DIRCTORY,
|
||||
TAOS_CFG_VTYPE_DOUBLE,
|
||||
};
|
||||
|
||||
enum {
|
||||
TAOS_CFG_UTYPE_NONE,
|
||||
TAOS_CFG_UTYPE_PERCENT,
|
||||
TAOS_CFG_UTYPE_GB,
|
||||
TAOS_CFG_UTYPE_MB,
|
||||
TAOS_CFG_UTYPE_BYTE,
|
||||
TAOS_CFG_UTYPE_SECOND,
|
||||
TAOS_CFG_UTYPE_MS
|
||||
};
|
||||
typedef struct SConfigItem {
|
||||
ECfgSrcType stype;
|
||||
ECfgDataType dtype;
|
||||
bool tsc;
|
||||
char *name;
|
||||
union {
|
||||
bool bval;
|
||||
float fval;
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
char *str;
|
||||
};
|
||||
union {
|
||||
int64_t imin;
|
||||
double fmin;
|
||||
};
|
||||
union {
|
||||
int64_t imax;
|
||||
double fmax;
|
||||
};
|
||||
SArray *array; // SDiskCfg
|
||||
} SConfigItem;
|
||||
|
||||
typedef struct {
|
||||
char * option;
|
||||
void * ptr;
|
||||
float minValue;
|
||||
float maxValue;
|
||||
int8_t cfgType;
|
||||
int8_t cfgStatus;
|
||||
int8_t unitType;
|
||||
int8_t valType;
|
||||
int32_t ptrLength;
|
||||
} SGlobalCfg;
|
||||
const char *name;
|
||||
const char *value;
|
||||
} SConfigPair;
|
||||
|
||||
extern SGlobalCfg tsGlobalConfig[];
|
||||
extern int32_t tsGlobalConfigNum;
|
||||
extern char * tsCfgStatusStr[];
|
||||
typedef struct SConfig SConfig;
|
||||
|
||||
void taosReadGlobalLogCfg();
|
||||
int32_t taosReadCfgFromFile();
|
||||
void taosPrintCfg();
|
||||
void taosDumpGlobalCfg();
|
||||
SConfig *cfgInit();
|
||||
int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const char *sourceStr);
|
||||
int32_t cfgLoadArray(SConfig *pCfg, SArray *pArgs); // SConfigPair
|
||||
void cfgCleanup(SConfig *pCfg);
|
||||
|
||||
void taosAddConfigOption(SGlobalCfg cfg);
|
||||
SGlobalCfg *taosGetConfigOption(const char *option);
|
||||
int32_t cfgGetSize(SConfig *pCfg);
|
||||
SConfigItem *cfgIterate(SConfig *pCfg, SConfigItem *pIter);
|
||||
void cfgCancelIterate(SConfig *pCfg, SConfigItem *pIter);
|
||||
SConfigItem *cfgGetItem(SConfig *pCfg, const char *name);
|
||||
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype);
|
||||
|
||||
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, bool tsc);
|
||||
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, bool tsc);
|
||||
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, bool tsc);
|
||||
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, double minval, double maxval, bool tsc);
|
||||
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc);
|
||||
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc);
|
||||
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal);
|
||||
int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal);
|
||||
int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal);
|
||||
|
||||
const char *cfgStypeStr(ECfgSrcType type);
|
||||
const char *cfgDtypeStr(ECfgDataType type);
|
||||
|
||||
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_CONFIG_H*/
|
||||
#endif /*_TD_CONFIG_H_*/
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef _TD_UTIL_DEF_H
|
||||
#define _TD_UTIL_DEF_H
|
||||
|
||||
|
@ -108,35 +110,52 @@ do { \
|
|||
(src) = (void *)((char *)src + sizeof(type));\
|
||||
} while(0)
|
||||
|
||||
typedef enum EOperatorType {
|
||||
// arithmetic operator
|
||||
OP_TYPE_ADD = 1,
|
||||
OP_TYPE_SUB,
|
||||
OP_TYPE_MULTI,
|
||||
OP_TYPE_DIV,
|
||||
OP_TYPE_MOD,
|
||||
|
||||
// TODO: check if below is necessary
|
||||
#define TSDB_RELATION_INVALID 0
|
||||
#define TSDB_RELATION_LESS 1
|
||||
#define TSDB_RELATION_GREATER 2
|
||||
#define TSDB_RELATION_EQUAL 3
|
||||
#define TSDB_RELATION_LESS_EQUAL 4
|
||||
#define TSDB_RELATION_GREATER_EQUAL 5
|
||||
#define TSDB_RELATION_NOT_EQUAL 6
|
||||
#define TSDB_RELATION_LIKE 7
|
||||
#define TSDB_RELATION_NOT_LIKE 8
|
||||
#define TSDB_RELATION_ISNULL 9
|
||||
#define TSDB_RELATION_NOTNULL 10
|
||||
#define TSDB_RELATION_IN 11
|
||||
#define TSDB_RELATION_NOT_IN 12
|
||||
// bit operator
|
||||
OP_TYPE_BIT_AND,
|
||||
OP_TYPE_BIT_OR,
|
||||
|
||||
#define TSDB_RELATION_AND 13
|
||||
#define TSDB_RELATION_OR 14
|
||||
#define TSDB_RELATION_NOT 15
|
||||
// comparison operator
|
||||
OP_TYPE_GREATER_THAN,
|
||||
OP_TYPE_GREATER_EQUAL,
|
||||
OP_TYPE_LOWER_THAN,
|
||||
OP_TYPE_LOWER_EQUAL,
|
||||
OP_TYPE_EQUAL,
|
||||
OP_TYPE_NOT_EQUAL,
|
||||
OP_TYPE_IN,
|
||||
OP_TYPE_NOT_IN,
|
||||
OP_TYPE_LIKE,
|
||||
OP_TYPE_NOT_LIKE,
|
||||
OP_TYPE_MATCH,
|
||||
OP_TYPE_NMATCH,
|
||||
OP_TYPE_IS_NULL,
|
||||
OP_TYPE_IS_NOT_NULL,
|
||||
OP_TYPE_IS_TRUE,
|
||||
OP_TYPE_IS_FALSE,
|
||||
OP_TYPE_IS_UNKNOWN,
|
||||
OP_TYPE_IS_NOT_TRUE,
|
||||
OP_TYPE_IS_NOT_FALSE,
|
||||
OP_TYPE_IS_NOT_UNKNOWN,
|
||||
|
||||
#define TSDB_RELATION_MATCH 16
|
||||
#define TSDB_RELATION_NMATCH 17
|
||||
// json operator
|
||||
OP_TYPE_JSON_GET_VALUE,
|
||||
OP_TYPE_JSON_CONTAINS
|
||||
} EOperatorType;
|
||||
|
||||
|
||||
typedef enum ELogicConditionType {
|
||||
LOGIC_COND_TYPE_AND,
|
||||
LOGIC_COND_TYPE_OR,
|
||||
LOGIC_COND_TYPE_NOT,
|
||||
} ELogicConditionType;
|
||||
|
||||
#define TSDB_BINARY_OP_ADD 4000
|
||||
#define TSDB_BINARY_OP_SUBTRACT 4001
|
||||
#define TSDB_BINARY_OP_MULTIPLY 4002
|
||||
#define TSDB_BINARY_OP_DIVIDE 4003
|
||||
#define TSDB_BINARY_OP_REMAINDER 4004
|
||||
#define TSDB_BINARY_OP_CONCAT 4005
|
||||
|
||||
#define FUNCTION_CEIL 4500
|
||||
#define FUNCTION_FLOOR 4501
|
||||
|
@ -148,9 +167,6 @@ do { \
|
|||
#define FUNCTION_LTRIM 4802
|
||||
#define FUNCTION_RTRIM 4803
|
||||
|
||||
#define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) < TSDB_RELATION_IN))
|
||||
#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_REMAINDER))
|
||||
|
||||
#define TSDB_NAME_DELIMITER_LEN 1
|
||||
|
||||
#define TSDB_UNI_LEN 24
|
||||
|
@ -182,6 +198,7 @@ do { \
|
|||
#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN
|
||||
#define TSDB_CONSUMER_GROUP_LEN 192
|
||||
#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CONSUMER_GROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
|
||||
#define TSDB_PARTITION_KEY_LEN (TSDB_CONSUMER_GROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
|
||||
#define TSDB_COL_NAME_LEN 65
|
||||
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
|
||||
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
|
||||
|
@ -335,9 +352,6 @@ do { \
|
|||
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type
|
||||
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode
|
||||
|
||||
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type
|
||||
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode
|
||||
|
||||
#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default
|
||||
|
||||
|
||||
|
|
|
@ -30,20 +30,20 @@ void tfCleanup();
|
|||
|
||||
// the same syntax as UNIX standard open/close/read/write
|
||||
// but FD is int64_t and will never be reused
|
||||
int64_t tfOpenRead(const char *pathname);
|
||||
int64_t tfOpenReadWrite(const char *pathname);
|
||||
int64_t tfOpenCreateWrite(const char *pathname);
|
||||
int64_t tfOpenCreateWriteAppend(const char *pathname);
|
||||
// int64_t tfOpenRead(const char *pathname);
|
||||
// int64_t tfOpenReadWrite(const char *pathname);
|
||||
// int64_t tfOpenCreateWrite(const char *pathname);
|
||||
// int64_t tfOpenCreateWriteAppend(const char *pathname);
|
||||
|
||||
int64_t tfClose(int64_t tfd);
|
||||
int64_t tfWrite(int64_t tfd, void *buf, int64_t count);
|
||||
int64_t tfRead(int64_t tfd, void *buf, int64_t count);
|
||||
int64_t tfPread(int64_t tfd, void *buf, int64_t count, int64_t offset);
|
||||
int32_t tfFsync(int64_t tfd);
|
||||
bool tfValid(int64_t tfd);
|
||||
int64_t tfLseek(int64_t tfd, int64_t offset, int32_t whence);
|
||||
int32_t tfFtruncate(int64_t tfd, int64_t length);
|
||||
void * tfMmapReadOnly(int64_t tfd, int64_t length);
|
||||
// int64_t tfClose(int64_t tfd);
|
||||
// int64_t tfWrite(int64_t tfd, void *buf, int64_t count);
|
||||
// int64_t tfRead(int64_t tfd, void *buf, int64_t count);
|
||||
// int64_t tfPread(int64_t tfd, void *buf, int64_t count, int64_t offset);
|
||||
// int32_t tfFsync(int64_t tfd);
|
||||
// bool tfValid(int64_t tfd);
|
||||
// int64_t tfLseek(int64_t tfd, int64_t offset, int32_t whence);
|
||||
// int32_t tfFtruncate(int64_t tfd, int64_t length);
|
||||
// void * tfMmapReadOnly(int64_t tfd, int64_t length);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// log
|
||||
extern int8_t tsAsyncLog;
|
||||
extern bool tsAsyncLog;
|
||||
extern int32_t tsNumOfLogLines;
|
||||
extern int32_t tsLogKeepDays;
|
||||
extern int32_t dDebugFlag;
|
||||
|
@ -32,9 +31,6 @@ extern int32_t mDebugFlag;
|
|||
extern int32_t cDebugFlag;
|
||||
extern int32_t jniDebugFlag;
|
||||
extern int32_t tmrDebugFlag;
|
||||
extern int32_t httpDebugFlag;
|
||||
extern int32_t mqttDebugFlag;
|
||||
extern int32_t monDebugFlag;
|
||||
extern int32_t uDebugFlag;
|
||||
extern int32_t rpcDebugFlag;
|
||||
extern int32_t qDebugFlag;
|
||||
|
@ -42,23 +38,23 @@ extern int32_t wDebugFlag;
|
|||
extern int32_t sDebugFlag;
|
||||
extern int32_t tsdbDebugFlag;
|
||||
extern int32_t tqDebugFlag;
|
||||
extern int32_t cqDebugFlag;
|
||||
extern int32_t debugFlag;
|
||||
|
||||
#define DEBUG_FATAL 1U
|
||||
#define DEBUG_ERROR DEBUG_FATAL
|
||||
#define DEBUG_WARN 2U
|
||||
#define DEBUG_INFO DEBUG_WARN
|
||||
#define DEBUG_DEBUG 4U
|
||||
#define DEBUG_TRACE 8U
|
||||
#define DEBUG_DUMP 16U
|
||||
extern int32_t fsDebugFlag;
|
||||
|
||||
#define DEBUG_FATAL 1U
|
||||
#define DEBUG_ERROR DEBUG_FATAL
|
||||
#define DEBUG_WARN 2U
|
||||
#define DEBUG_INFO DEBUG_WARN
|
||||
#define DEBUG_DEBUG 4U
|
||||
#define DEBUG_TRACE 8U
|
||||
#define DEBUG_DUMP 16U
|
||||
#define DEBUG_SCREEN 64U
|
||||
#define DEBUG_FILE 128U
|
||||
#define DEBUG_FILE 128U
|
||||
|
||||
int32_t taosInitLog(char *logName, int32_t numOfLogLines, int32_t maxFiles);
|
||||
int32_t taosInitLog(const char *logName, int32_t maxFiles);
|
||||
void taosCloseLog();
|
||||
void taosResetLog();
|
||||
void taosSetAllDebugFlag(int32_t flag);
|
||||
void taosDumpData(uint8_t *msg, int32_t len);
|
||||
|
||||
void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...)
|
||||
#ifdef __GNUC__
|
||||
|
@ -72,7 +68,17 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
|
|||
#endif
|
||||
;
|
||||
|
||||
void taosDumpData(unsigned char *msg, int32_t len);
|
||||
extern int8_t tscEmbeddedInUtil;
|
||||
|
||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
|
||||
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
|
||||
|
||||
#define pError(...) { taosPrintLog("APP ERROR ", 255, __VA_ARGS__); }
|
||||
#define pPrint(...) { taosPrintLog("APP ", 255, __VA_ARGS__); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,64 +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_UTIL_NOTE_H
|
||||
#define _TD_UTIL_NOTE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_NOTE_LINE_SIZE 66000
|
||||
#define NOTE_FILE_NAME_LEN 300
|
||||
|
||||
typedef struct {
|
||||
int32_t fileNum;
|
||||
int32_t maxLines;
|
||||
int32_t lines;
|
||||
int32_t flag;
|
||||
int32_t fd;
|
||||
int32_t openInProgress;
|
||||
char name[NOTE_FILE_NAME_LEN];
|
||||
pthread_mutex_t mutex;
|
||||
} SNoteObj;
|
||||
|
||||
extern SNoteObj tsHttpNote;
|
||||
extern SNoteObj tsTscNote;
|
||||
extern SNoteObj tsInfoNote;
|
||||
|
||||
int32_t taosInitNotes();
|
||||
void taosNotePrint(SNoteObj* pNote, const char* const format, ...);
|
||||
void taosNotePrintBuffer(SNoteObj* pNote, char* buffer, int32_t len);
|
||||
|
||||
#define nPrintHttp(...) \
|
||||
if (tsHttpEnableRecordSql) { \
|
||||
taosNotePrint(&tsHttpNote, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define nPrintTsc(...) \
|
||||
if (tsTscEnableRecordSql) { \
|
||||
taosNotePrint(&tsTscNote, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define nInfo(buffer, len) \
|
||||
if (tscEmbeddedInUtil == 1) { \
|
||||
taosNotePrintBuffer(&tsInfoNote, buffer, len); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_NOTE_H*/
|
|
@ -26,7 +26,6 @@ typedef void *tmr_h;
|
|||
typedef void (*TAOS_TMR_CALLBACK)(void *, void *);
|
||||
|
||||
extern int taosTmrThreads;
|
||||
extern uint32_t tsMaxTmrCtrl;
|
||||
|
||||
#define MSECONDS_PER_TICK 5
|
||||
|
||||
|
|
|
@ -1,43 +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_UTIL_ULOG_H
|
||||
#define _TD_UTIL_ULOG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "tlog.h"
|
||||
|
||||
extern int32_t uDebugFlag;
|
||||
extern int8_t tscEmbeddedInUtil;
|
||||
|
||||
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
|
||||
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
|
||||
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
|
||||
|
||||
#define pError(...) { taosPrintLog("APP ERROR ", 255, __VA_ARGS__); }
|
||||
#define pPrint(...) { taosPrintLog("APP ", 255, __VA_ARGS__); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_ULOG_H*/
|
|
@ -13,17 +13,21 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_COMMON_LOCALE_H_
|
||||
#define _TD_COMMON_LOCALE_H_
|
||||
#ifndef _TD_UTIL_VERSION_H
|
||||
#define _TD_UTIL_VERSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void tsSetLocale();
|
||||
extern char version[];
|
||||
extern char compatible_version[];
|
||||
extern char gitinfo[];
|
||||
extern char gitinfoOfInternal[];
|
||||
extern char buildinfo[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*_TD_COMMON_LOCALE_H_*/
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_VERSION_H*/
|
|
@ -20,17 +20,19 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "taos.h"
|
||||
#include "common.h"
|
||||
#include "tmsg.h"
|
||||
#include "parser.h"
|
||||
#include "query.h"
|
||||
#include "taos.h"
|
||||
#include "tdef.h"
|
||||
#include "tep.h"
|
||||
#include "thash.h"
|
||||
#include "tlist.h"
|
||||
#include "tmsg.h"
|
||||
#include "tmsgtype.h"
|
||||
#include "trpc.h"
|
||||
#include "query.h"
|
||||
#include "parser.h"
|
||||
|
||||
#include "tconfig.h"
|
||||
|
||||
#define CHECK_CODE_GOTO(expr, label) \
|
||||
do { \
|
||||
|
@ -46,12 +48,12 @@ extern "C" {
|
|||
typedef struct SAppInstInfo SAppInstInfo;
|
||||
|
||||
typedef struct SHbConnInfo {
|
||||
void *param;
|
||||
SClientHbReq *req;
|
||||
void* param;
|
||||
SClientHbReq* req;
|
||||
} SHbConnInfo;
|
||||
|
||||
typedef struct SAppHbMgr {
|
||||
char *key;
|
||||
char* key;
|
||||
// statistics
|
||||
int32_t reportCnt;
|
||||
int32_t connKeyCnt;
|
||||
|
@ -62,15 +64,13 @@ typedef struct SAppHbMgr {
|
|||
// connection
|
||||
SAppInstInfo* pAppInstInfo;
|
||||
// info
|
||||
SHashObj* activeInfo; // hash<SClientHbKey, SClientHbReq>
|
||||
SHashObj* connInfo; // hash<SClientHbKey, SHbConnInfo>
|
||||
SHashObj* activeInfo; // hash<SClientHbKey, SClientHbReq>
|
||||
SHashObj* connInfo; // hash<SClientHbKey, SHbConnInfo>
|
||||
} SAppHbMgr;
|
||||
|
||||
typedef int32_t (*FHbRspHandle)(struct SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp);
|
||||
|
||||
typedef int32_t (*FHbRspHandle)(struct SAppHbMgr *pAppHbMgr, SClientHbRsp* pRsp);
|
||||
|
||||
typedef int32_t (*FHbReqHandle)(SClientHbKey *connKey, void* param, SClientHbReq *req);
|
||||
|
||||
typedef int32_t (*FHbReqHandle)(SClientHbKey* connKey, void* param, SClientHbReq* req);
|
||||
|
||||
typedef struct SClientHbMgr {
|
||||
int8_t inited;
|
||||
|
@ -83,63 +83,62 @@ typedef struct SClientHbMgr {
|
|||
FHbRspHandle rspHandle[HEARTBEAT_TYPE_MAX];
|
||||
} SClientHbMgr;
|
||||
|
||||
|
||||
typedef struct SQueryExecMetric {
|
||||
int64_t start; // start timestamp
|
||||
int64_t parsed; // start to parse
|
||||
int64_t send; // start to send to server
|
||||
int64_t rsp; // receive response from server
|
||||
int64_t start; // start timestamp
|
||||
int64_t parsed; // start to parse
|
||||
int64_t send; // start to send to server
|
||||
int64_t rsp; // receive response from server
|
||||
} SQueryExecMetric;
|
||||
|
||||
typedef struct SInstanceSummary {
|
||||
uint64_t numOfInsertsReq;
|
||||
uint64_t numOfInsertRows;
|
||||
uint64_t insertElapsedTime;
|
||||
uint64_t insertBytes; // submit to tsdb since launched.
|
||||
uint64_t numOfInsertsReq;
|
||||
uint64_t numOfInsertRows;
|
||||
uint64_t insertElapsedTime;
|
||||
uint64_t insertBytes; // submit to tsdb since launched.
|
||||
|
||||
uint64_t fetchBytes;
|
||||
uint64_t queryElapsedTime;
|
||||
uint64_t numOfSlowQueries;
|
||||
uint64_t totalRequests;
|
||||
uint64_t currentRequests; // the number of SRequestObj
|
||||
uint64_t fetchBytes;
|
||||
uint64_t queryElapsedTime;
|
||||
uint64_t numOfSlowQueries;
|
||||
uint64_t totalRequests;
|
||||
uint64_t currentRequests; // the number of SRequestObj
|
||||
} SInstanceSummary;
|
||||
|
||||
typedef struct SHeartBeatInfo {
|
||||
void *pTimer; // timer, used to send request msg to mnode
|
||||
void* pTimer; // timer, used to send request msg to mnode
|
||||
} SHeartBeatInfo;
|
||||
|
||||
struct SAppInstInfo {
|
||||
int64_t numOfConns;
|
||||
SCorEpSet mgmtEp;
|
||||
SInstanceSummary summary;
|
||||
SList *pConnList; // STscObj linked list
|
||||
int64_t clusterId;
|
||||
void *pTransporter;
|
||||
struct SAppHbMgr *pAppHbMgr;
|
||||
int64_t numOfConns;
|
||||
SCorEpSet mgmtEp;
|
||||
SInstanceSummary summary;
|
||||
SList* pConnList; // STscObj linked list
|
||||
int64_t clusterId;
|
||||
void* pTransporter;
|
||||
struct SAppHbMgr* pAppHbMgr;
|
||||
};
|
||||
|
||||
typedef struct SAppInfo {
|
||||
int64_t startTime;
|
||||
char appName[TSDB_APP_NAME_LEN];
|
||||
char *ep;
|
||||
char* ep;
|
||||
int32_t pid;
|
||||
int32_t numOfThreads;
|
||||
SHashObj *pInstMap;
|
||||
SHashObj* pInstMap;
|
||||
pthread_mutex_t mutex;
|
||||
} SAppInfo;
|
||||
|
||||
typedef struct STscObj {
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
char ver[128];
|
||||
int32_t acctId;
|
||||
uint32_t connId;
|
||||
int32_t connType;
|
||||
uint64_t id; // ref ID returned by taosAddRef
|
||||
pthread_mutex_t mutex; // used to protect the operation on db
|
||||
int32_t numOfReqs; // number of sqlObj bound to this connection
|
||||
SAppInstInfo *pAppInfo;
|
||||
char user[TSDB_USER_LEN];
|
||||
char pass[TSDB_PASSWORD_LEN];
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
char ver[128];
|
||||
int32_t acctId;
|
||||
uint32_t connId;
|
||||
int32_t connType;
|
||||
uint64_t id; // ref ID returned by taosAddRef
|
||||
pthread_mutex_t mutex; // used to protect the operation on db
|
||||
int32_t numOfReqs; // number of sqlObj bound to this connection
|
||||
SAppInstInfo* pAppInfo;
|
||||
} STscObj;
|
||||
|
||||
typedef struct SMqConsumer {
|
||||
|
@ -147,49 +146,49 @@ typedef struct SMqConsumer {
|
|||
} SMqConsumer;
|
||||
|
||||
typedef struct SReqResultInfo {
|
||||
const char *pRspMsg;
|
||||
const char *pData;
|
||||
TAOS_FIELD *fields;
|
||||
uint32_t numOfCols;
|
||||
int32_t *length;
|
||||
TAOS_ROW row;
|
||||
char **pCol;
|
||||
uint32_t numOfRows;
|
||||
uint64_t totalRows;
|
||||
uint32_t current;
|
||||
bool completed;
|
||||
const char* pRspMsg;
|
||||
const char* pData;
|
||||
TAOS_FIELD* fields;
|
||||
uint32_t numOfCols;
|
||||
int32_t* length;
|
||||
TAOS_ROW row;
|
||||
char** pCol;
|
||||
uint32_t numOfRows;
|
||||
uint64_t totalRows;
|
||||
uint32_t current;
|
||||
bool completed;
|
||||
} SReqResultInfo;
|
||||
|
||||
typedef struct SShowReqInfo {
|
||||
int64_t execId; // showId/queryId
|
||||
int32_t vgId;
|
||||
SArray *pArray; // SArray<SVgroupInfo>
|
||||
int32_t currentIndex; // current accessed vgroup index.
|
||||
int64_t execId; // showId/queryId
|
||||
int32_t vgId;
|
||||
SArray* pArray; // SArray<SVgroupInfo>
|
||||
int32_t currentIndex; // current accessed vgroup index.
|
||||
} SShowReqInfo;
|
||||
|
||||
typedef struct SRequestSendRecvBody {
|
||||
tsem_t rspSem; // not used now
|
||||
tsem_t rspSem; // not used now
|
||||
void* fp;
|
||||
SShowReqInfo showInfo; // todo this attribute will be removed after the query framework being completed.
|
||||
SShowReqInfo showInfo; // todo this attribute will be removed after the query framework being completed.
|
||||
SDataBuf requestMsg;
|
||||
struct SSchJob *pQueryJob; // query job, created according to sql query DAG.
|
||||
struct SQueryDag *pDag; // the query dag, generated according to the sql statement.
|
||||
struct SSchJob* pQueryJob; // query job, created according to sql query DAG.
|
||||
struct SQueryDag* pDag; // the query dag, generated according to the sql statement.
|
||||
SReqResultInfo resInfo;
|
||||
} SRequestSendRecvBody;
|
||||
|
||||
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
|
||||
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
|
||||
|
||||
typedef struct SRequestObj {
|
||||
uint64_t requestId;
|
||||
int32_t type; // request type
|
||||
STscObj *pTscObj;
|
||||
char *sqlstr; // sql string
|
||||
int32_t sqlLen;
|
||||
int64_t self;
|
||||
char *msgBuf;
|
||||
void *pInfo; // sql parse info, generated by parser module
|
||||
int32_t code;
|
||||
SQueryExecMetric metric;
|
||||
uint64_t requestId;
|
||||
int32_t type; // request type
|
||||
STscObj* pTscObj;
|
||||
char* sqlstr; // sql string
|
||||
int32_t sqlLen;
|
||||
int64_t self;
|
||||
char* msgBuf;
|
||||
void* pInfo; // sql parse info, generated by parser module
|
||||
int32_t code;
|
||||
SQueryExecMetric metric;
|
||||
SRequestSendRecvBody body;
|
||||
} SRequestObj;
|
||||
|
||||
|
@ -198,51 +197,52 @@ extern int32_t clientReqRefPool;
|
|||
extern int32_t clientConnRefPool;
|
||||
|
||||
extern int (*handleRequestRspFp[TDMT_MAX])(void*, const SDataBuf* pMsg, int32_t code);
|
||||
int genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code);
|
||||
int genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code);
|
||||
SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pReqObj);
|
||||
|
||||
int taos_init();
|
||||
int taos_init();
|
||||
|
||||
void* createTscObj(const char* user, const char* auth, const char *db, SAppInstInfo* pAppInfo);
|
||||
void destroyTscObj(void*pObj);
|
||||
void* createTscObj(const char* user, const char* auth, const char* db, SAppInstInfo* pAppInfo);
|
||||
void destroyTscObj(void* pObj);
|
||||
|
||||
uint64_t generateRequestId();
|
||||
|
||||
void *createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type);
|
||||
void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type);
|
||||
void destroyRequest(SRequestObj* pRequest);
|
||||
|
||||
char *getDbOfConnection(STscObj* pObj);
|
||||
char* getDbOfConnection(STscObj* pObj);
|
||||
void setConnectionDB(STscObj* pTscObj, const char* db);
|
||||
|
||||
void taos_init_imp(void);
|
||||
int taos_options_imp(TSDB_OPTION option, const char *str);
|
||||
int taos_options_imp(TSDB_OPTION option, const char* str);
|
||||
|
||||
void* openTransporter(const char *user, const char *auth, int32_t numOfThreads);
|
||||
void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
|
||||
|
||||
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType);
|
||||
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
||||
|
||||
void initMsgHandleFp();
|
||||
|
||||
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port);
|
||||
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||
uint16_t port);
|
||||
|
||||
void *doFetchRow(SRequestObj* pRequest);
|
||||
void* doFetchRow(SRequestObj* pRequest);
|
||||
|
||||
void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows);
|
||||
void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows);
|
||||
|
||||
|
||||
int32_t buildRequest(STscObj *pTscObj, const char *sql, int sqlLen, SRequestObj** pRequest);
|
||||
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest);
|
||||
|
||||
int32_t parseSql(SRequestObj* pRequest, SQueryNode** pQuery);
|
||||
|
||||
// --- heartbeat
|
||||
// --- heartbeat
|
||||
// global, called by mgmt
|
||||
int hbMgrInit();
|
||||
void hbMgrCleanUp();
|
||||
int hbHandleRsp(SClientHbBatchRsp* hbRsp);
|
||||
|
||||
// cluster level
|
||||
SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char *key);
|
||||
void appHbMgrCleanup(void);
|
||||
SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key);
|
||||
void appHbMgrCleanup(void);
|
||||
|
||||
// conn level
|
||||
int hbRegisterConn(SAppHbMgr* pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType);
|
||||
|
@ -253,7 +253,6 @@ int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* v
|
|||
// --- mq
|
||||
void hbMgrInitMqHbRspHandle();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -13,33 +13,30 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "os.h"
|
||||
#include "catalog.h"
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
#include "os.h"
|
||||
#include "query.h"
|
||||
#include "scheduler.h"
|
||||
#include "tmsg.h"
|
||||
#include "tcache.h"
|
||||
#include "tconfig.h"
|
||||
#include "tglobal.h"
|
||||
#include "tnote.h"
|
||||
#include "tmsg.h"
|
||||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
#include "ttime.h"
|
||||
#include "ttimezone.h"
|
||||
|
||||
#define TSC_VAR_NOT_RELEASE 1
|
||||
#define TSC_VAR_RELEASED 0
|
||||
#define TSC_VAR_RELEASED 0
|
||||
|
||||
SAppInfo appInfo;
|
||||
int32_t clientReqRefPool = -1;
|
||||
int32_t clientConnRefPool = -1;
|
||||
SAppInfo appInfo;
|
||||
int32_t clientReqRefPool = -1;
|
||||
int32_t clientConnRefPool = -1;
|
||||
|
||||
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
||||
volatile int32_t tscInitRes = 0;
|
||||
volatile int32_t tscInitRes = 0;
|
||||
|
||||
static void registerRequest(SRequestObj* pRequest) {
|
||||
static void registerRequest(SRequestObj *pRequest) {
|
||||
STscObj *pTscObj = (STscObj *)taosAcquireRef(clientConnRefPool, pRequest->pTscObj->id);
|
||||
assert(pTscObj != NULL);
|
||||
|
||||
|
@ -53,60 +50,49 @@ static void registerRequest(SRequestObj* pRequest) {
|
|||
|
||||
int32_t total = atomic_add_fetch_32(&pSummary->totalRequests, 1);
|
||||
int32_t currentInst = atomic_add_fetch_32(&pSummary->currentRequests, 1);
|
||||
tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64 ", current:%d, app current:%d, total:%d, reqId:0x%"PRIx64, pRequest->self,
|
||||
pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
|
||||
tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64
|
||||
", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
|
||||
}
|
||||
}
|
||||
|
||||
static void deregisterRequest(SRequestObj* pRequest) {
|
||||
static void deregisterRequest(SRequestObj *pRequest) {
|
||||
assert(pRequest != NULL);
|
||||
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
SInstanceSummary* pActivity = &pTscObj->pAppInfo->summary;
|
||||
STscObj * pTscObj = pRequest->pTscObj;
|
||||
SInstanceSummary *pActivity = &pTscObj->pAppInfo->summary;
|
||||
|
||||
int32_t currentInst = atomic_sub_fetch_32(&pActivity->currentRequests, 1);
|
||||
int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1);
|
||||
|
||||
int64_t duration = taosGetTimestampMs() - pRequest->metric.start;
|
||||
tscDebug("0x%"PRIx64" free Request from connObj: 0x%"PRIx64", reqId:0x%"PRIx64" elapsed:%"PRIu64" ms, current:%d, app current:%d", pRequest->self, pTscObj->id,
|
||||
pRequest->requestId, duration, num, currentInst);
|
||||
tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64
|
||||
" ms, current:%d, app current:%d",
|
||||
pRequest->self, pTscObj->id, pRequest->requestId, duration, num, currentInst);
|
||||
taosReleaseRef(clientConnRefPool, pTscObj->id);
|
||||
}
|
||||
|
||||
static void tscInitLogFile() {
|
||||
taosReadGlobalLogCfg();
|
||||
if (mkdir(tsLogDir, 0755) != 0 && errno != EEXIST) {
|
||||
printf("failed to create log dir:%s\n", tsLogDir);
|
||||
}
|
||||
|
||||
const char *defaultLogFileNamePrefix = "taoslog";
|
||||
const int32_t maxLogFileNum = 10;
|
||||
|
||||
char temp[128] = {0};
|
||||
sprintf(temp, "%s/%s", tsLogDir, defaultLogFileNamePrefix);
|
||||
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
|
||||
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||
}
|
||||
}
|
||||
|
||||
// todo close the transporter properly
|
||||
void closeTransporter(STscObj* pTscObj) {
|
||||
void closeTransporter(STscObj *pTscObj) {
|
||||
if (pTscObj == NULL || pTscObj->pAppInfo->pTransporter == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
tscDebug("free transporter:%p in connObj: 0x%"PRIx64, pTscObj->pAppInfo->pTransporter, pTscObj->id);
|
||||
tscDebug("free transporter:%p in connObj: 0x%" PRIx64, pTscObj->pAppInfo->pTransporter, pTscObj->id);
|
||||
rpcClose(pTscObj->pAppInfo->pTransporter);
|
||||
}
|
||||
|
||||
// TODO refactor
|
||||
void* openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||
void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||
SRpcInit rpcInit;
|
||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
rpcInit.localPort = 0;
|
||||
rpcInit.label = "TSC";
|
||||
rpcInit.numOfThreads = numOfThread;
|
||||
rpcInit.cfp = processMsgFromServer;
|
||||
rpcInit.pfp = persistConnForSpecificMsg;
|
||||
rpcInit.sessions = tsMaxConnections;
|
||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||
rpcInit.user = (char *)user;
|
||||
|
@ -115,7 +101,7 @@ void* openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
rpcInit.spi = 1;
|
||||
rpcInit.secret = (char *)auth;
|
||||
|
||||
void* pDnodeConn = rpcOpen(&rpcInit);
|
||||
void *pDnodeConn = rpcOpen(&rpcInit);
|
||||
if (pDnodeConn == NULL) {
|
||||
tscError("failed to init connection to server");
|
||||
return NULL;
|
||||
|
@ -130,12 +116,12 @@ void destroyTscObj(void *pObj) {
|
|||
SClientHbKey connKey = {.connId = pTscObj->connId, .hbType = pTscObj->connType};
|
||||
hbDeregisterConn(pTscObj->pAppInfo->pAppHbMgr, connKey);
|
||||
atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
tscDebug("connObj 0x%"PRIx64" destroyed, totalConn:%"PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
||||
tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
||||
pthread_mutex_destroy(&pTscObj->mutex);
|
||||
tfree(pTscObj);
|
||||
}
|
||||
|
||||
void* createTscObj(const char* user, const char* auth, const char *db, SAppInstInfo* pAppInfo) {
|
||||
void *createTscObj(const char *user, const char *auth, const char *db, SAppInstInfo *pAppInfo) {
|
||||
STscObj *pObj = (STscObj *)calloc(1, sizeof(STscObj));
|
||||
if (NULL == pObj) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
|
@ -153,11 +139,11 @@ void* createTscObj(const char* user, const char* auth, const char *db, SAppInstI
|
|||
pthread_mutex_init(&pObj->mutex, NULL);
|
||||
pObj->id = taosAddRef(clientConnRefPool, pObj);
|
||||
|
||||
tscDebug("connObj created, 0x%"PRIx64, pObj->id);
|
||||
tscDebug("connObj created, 0x%" PRIx64, pObj->id);
|
||||
return pObj;
|
||||
}
|
||||
|
||||
void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type) {
|
||||
void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) {
|
||||
assert(pObj != NULL);
|
||||
|
||||
SRequestObj *pRequest = (SRequestObj *)calloc(1, sizeof(SRequestObj));
|
||||
|
@ -166,20 +152,20 @@ void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t ty
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pRequest->requestId = generateRequestId();
|
||||
pRequest->requestId = generateRequestId();
|
||||
pRequest->metric.start = taosGetTimestampMs();
|
||||
|
||||
pRequest->type = type;
|
||||
pRequest->pTscObj = pObj;
|
||||
pRequest->body.fp = fp; // not used it yet
|
||||
pRequest->msgBuf = calloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
pRequest->type = type;
|
||||
pRequest->pTscObj = pObj;
|
||||
pRequest->body.fp = fp; // not used it yet
|
||||
pRequest->msgBuf = calloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
tsem_init(&pRequest->body.rspSem, 0, 0);
|
||||
|
||||
registerRequest(pRequest);
|
||||
return pRequest;
|
||||
}
|
||||
|
||||
static void doFreeReqResultInfo(SReqResultInfo* pResInfo) {
|
||||
static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
||||
tfree(pResInfo->pRspMsg);
|
||||
tfree(pResInfo->length);
|
||||
tfree(pResInfo->row);
|
||||
|
@ -187,9 +173,9 @@ static void doFreeReqResultInfo(SReqResultInfo* pResInfo) {
|
|||
tfree(pResInfo->fields);
|
||||
}
|
||||
|
||||
static void doDestroyRequest(void* p) {
|
||||
static void doDestroyRequest(void *p) {
|
||||
assert(p != NULL);
|
||||
SRequestObj* pRequest = (SRequestObj*)p;
|
||||
SRequestObj *pRequest = (SRequestObj *)p;
|
||||
|
||||
assert(RID_VALID(pRequest->self));
|
||||
|
||||
|
@ -208,7 +194,7 @@ static void doDestroyRequest(void* p) {
|
|||
tfree(pRequest);
|
||||
}
|
||||
|
||||
void destroyRequest(SRequestObj* pRequest) {
|
||||
void destroyRequest(SRequestObj *pRequest) {
|
||||
if (pRequest == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -225,16 +211,17 @@ void taos_init_imp(void) {
|
|||
srand(taosGetTimestampSec());
|
||||
|
||||
deltaToUtcInitOnce();
|
||||
taosInitGlobalCfg();
|
||||
taosReadCfgFromFile();
|
||||
|
||||
tscInitLogFile();
|
||||
if (taosCheckAndPrintCfg()) {
|
||||
if (taosCreateLog("taoslog", 10, configDir, NULL, NULL, NULL, 1) != 0) {
|
||||
tscInitRes = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (taosInitCfg(configDir, NULL, NULL, NULL, 1) != 0) {
|
||||
tscInitRes = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
taosInitNotes();
|
||||
initMsgHandleFp();
|
||||
initQueryModuleMsgHandle();
|
||||
|
||||
|
@ -245,21 +232,21 @@ void taos_init_imp(void) {
|
|||
|
||||
SSchedulerCfg scfg = {.maxJobNum = 100};
|
||||
schedulerInit(&scfg);
|
||||
tscDebug("starting to initialize TAOS driver, local ep: %s", tsLocalEp);
|
||||
tscDebug("starting to initialize TAOS driver");
|
||||
|
||||
taosSetCoreDump(true);
|
||||
|
||||
initTaskQueue();
|
||||
|
||||
clientConnRefPool = taosOpenRef(200, destroyTscObj);
|
||||
clientReqRefPool = taosOpenRef(40960, doDestroyRequest);
|
||||
clientReqRefPool = taosOpenRef(40960, doDestroyRequest);
|
||||
|
||||
taosGetAppName(appInfo.appName, NULL);
|
||||
pthread_mutex_init(&appInfo.mutex, NULL);
|
||||
|
||||
appInfo.pid = taosGetPId();
|
||||
appInfo.pid = taosGetPId();
|
||||
appInfo.startTime = taosGetTimestampMs();
|
||||
appInfo.pInstMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
appInfo.pInstMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
tscDebug("client is initialized successfully");
|
||||
}
|
||||
|
||||
|
@ -269,6 +256,7 @@ int taos_init() {
|
|||
}
|
||||
|
||||
int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||
#if 0
|
||||
SGlobalCfg *cfg = NULL;
|
||||
|
||||
switch (option) {
|
||||
|
@ -281,7 +269,8 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
tscInfo("set config file directory:%s", str);
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
|
||||
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -296,7 +285,8 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
tscInfo("set shellActivityTimer:%d", tsShellActivityTimer);
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], *(int32_t *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, str,
|
||||
tsCfgStatusStr[cfg->cfgStatus], *(int32_t *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -305,7 +295,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
assert(cfg != NULL);
|
||||
|
||||
size_t len = strlen(str);
|
||||
if (len == 0 || len > TSDB_LOCALE_LEN) {
|
||||
if (len == 0 || len > TD_LOCALE_LEN) {
|
||||
tscInfo("Invalid locale:%s, use default", str);
|
||||
return -1;
|
||||
}
|
||||
|
@ -313,8 +303,8 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||
char sep = '.';
|
||||
|
||||
if (strlen(tsLocale) == 0) { // locale does not set yet
|
||||
char* defaultLocale = setlocale(LC_CTYPE, "");
|
||||
if (strlen(tsLocale) == 0) { // locale does not set yet
|
||||
char *defaultLocale = setlocale(LC_CTYPE, "");
|
||||
|
||||
// The locale of the current OS does not be set correctly, so the default locale cannot be acquired.
|
||||
// The launch of current system will abort soon.
|
||||
|
@ -323,21 +313,21 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
tstrncpy(tsLocale, defaultLocale, TSDB_LOCALE_LEN);
|
||||
tstrncpy(tsLocale, defaultLocale, TD_LOCALE_LEN);
|
||||
}
|
||||
|
||||
// set the user specified locale
|
||||
char *locale = setlocale(LC_CTYPE, str);
|
||||
|
||||
if (locale != NULL) { // failed to set the user specified locale
|
||||
if (locale != NULL) { // failed to set the user specified locale
|
||||
tscInfo("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
} else { // set the user specified locale failed, use default LC_CTYPE as current locale
|
||||
} else { // set the user specified locale failed, use default LC_CTYPE as current locale
|
||||
locale = setlocale(LC_CTYPE, tsLocale);
|
||||
tscInfo("failed to set locale:%s, current locale:%s", str, tsLocale);
|
||||
}
|
||||
|
||||
tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);
|
||||
tstrncpy(tsLocale, locale, TD_LOCALE_LEN);
|
||||
|
||||
char *charset = strrchr(tsLocale, sep);
|
||||
if (charset != NULL) {
|
||||
|
@ -352,7 +342,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
tscInfo("charset changed from %s to %s", tsCharset, charset);
|
||||
}
|
||||
|
||||
tstrncpy(tsCharset, charset, TSDB_LOCALE_LEN);
|
||||
tstrncpy(tsCharset, charset, TD_LOCALE_LEN);
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
|
||||
} else {
|
||||
|
@ -360,11 +350,12 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
}
|
||||
|
||||
free(charset);
|
||||
} else { // it may be windows system
|
||||
} else { // it may be windows system
|
||||
tscInfo("charset remains:%s", tsCharset);
|
||||
}
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
|
||||
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -375,7 +366,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
assert(cfg != NULL);
|
||||
|
||||
size_t len = strlen(str);
|
||||
if (len == 0 || len > TSDB_LOCALE_LEN) {
|
||||
if (len == 0 || len > TD_LOCALE_LEN) {
|
||||
tscInfo("failed to set charset:%s", str);
|
||||
return -1;
|
||||
}
|
||||
|
@ -388,13 +379,14 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
tscInfo("charset changed from %s to %s", tsCharset, str);
|
||||
}
|
||||
|
||||
tstrncpy(tsCharset, str, TSDB_LOCALE_LEN);
|
||||
tstrncpy(tsCharset, str, TD_LOCALE_LEN);
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
} else {
|
||||
tscInfo("charset:%s not valid", str);
|
||||
}
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
|
||||
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -405,12 +397,13 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
assert(cfg != NULL);
|
||||
|
||||
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
|
||||
tstrncpy(tsTimezone, str, TSDB_TIMEZONE_LEN);
|
||||
tstrncpy(tsTimezone, str, TD_TIMEZONE_LEN);
|
||||
tsSetTimeZone();
|
||||
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
|
||||
tscDebug("timezone set:%s, input:%s by taos_options", tsTimezone, str);
|
||||
} else {
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str, tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
|
||||
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -419,7 +412,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
tscError("Invalid option %d", option);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -434,7 +427,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
*/
|
||||
uint64_t generateRequestId() {
|
||||
static uint64_t hashId = 0;
|
||||
static int32_t requestSerialId = 0;
|
||||
static int32_t requestSerialId = 0;
|
||||
|
||||
if (hashId == 0) {
|
||||
char uid[64] = {0};
|
||||
|
@ -448,9 +441,9 @@ uint64_t generateRequestId() {
|
|||
}
|
||||
}
|
||||
|
||||
int64_t ts = taosGetTimestampMs();
|
||||
uint64_t pid = taosGetPId();
|
||||
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||
int64_t ts = taosGetTimestampMs();
|
||||
uint64_t pid = taosGetPId();
|
||||
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||
|
||||
uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
||||
return id;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "tep.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsgtype.h"
|
||||
#include "tnote.h"
|
||||
#include "tpagedbuf.h"
|
||||
#include "tref.h"
|
||||
|
||||
|
@ -254,11 +253,9 @@ TAOS_RES* taos_query_l(TAOS* taos, const char* sql, int sqlLen) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
nPrintTsc("%s", sql)
|
||||
|
||||
SRequestObj* pRequest = NULL;
|
||||
SQueryNode* pQueryNode = NULL;
|
||||
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
||||
SRequestObj* pRequest = NULL;
|
||||
SQueryNode* pQueryNode = NULL;
|
||||
SArray* pNodeList = taosArrayInit(4, sizeof(struct SQueryNodeAddr));
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return);
|
||||
|
@ -370,7 +367,6 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
|||
pMsgSendInfo->fp = handleRequestRspFp[TMSG_INDEX(pMsgSendInfo->msgType)];
|
||||
pMsgSendInfo->param = pRequest;
|
||||
|
||||
|
||||
SConnectReq connectReq = {0};
|
||||
STscObj* pObj = pRequest->pTscObj;
|
||||
|
||||
|
@ -398,7 +394,9 @@ static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
|
|||
tfree(pMsgBody->msgInfo.pData);
|
||||
tfree(pMsgBody);
|
||||
}
|
||||
|
||||
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType) {
|
||||
return msgType == TDMT_VND_QUERY_RSP || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP;
|
||||
}
|
||||
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->ahandle;
|
||||
assert(pMsg->ahandle != NULL);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "tmsg.h"
|
||||
#include "tglobal.h"
|
||||
#include "catalog.h"
|
||||
#include "version.h"
|
||||
|
||||
#define TSC_VAR_NOT_RELEASE 1
|
||||
#define TSC_VAR_RELEASED 0
|
||||
|
@ -56,9 +57,7 @@ void taos_cleanup(void) {
|
|||
}
|
||||
|
||||
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
|
||||
int32_t p = (port != 0) ? port : tsServerPort;
|
||||
|
||||
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, p, user, db);
|
||||
tscDebug("try to connect to %s:%u, user:%s db:%s", ip, port, user, db);
|
||||
if (user == NULL) {
|
||||
user = TSDB_DEFAULT_USER;
|
||||
}
|
||||
|
@ -67,7 +66,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
|||
pass = TSDB_DEFAULT_PASS;
|
||||
}
|
||||
|
||||
return taos_connect_internal(ip, user, pass, NULL, db, p);
|
||||
return taos_connect_internal(ip, user, pass, NULL, db, port);
|
||||
}
|
||||
|
||||
void taos_close(TAOS* taos) {
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "tep.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsgtype.h"
|
||||
#include "tnote.h"
|
||||
#include "tpagedbuf.h"
|
||||
#include "tref.h"
|
||||
|
||||
|
@ -45,22 +44,24 @@ struct tmq_topic_vgroup_list_t {
|
|||
};
|
||||
|
||||
struct tmq_conf_t {
|
||||
char clientId[256];
|
||||
char groupId[256];
|
||||
bool auto_commit;
|
||||
char clientId[256];
|
||||
char groupId[256];
|
||||
int8_t auto_commit;
|
||||
int8_t resetOffset;
|
||||
tmq_commit_cb* commit_cb;
|
||||
/*char* ip;*/
|
||||
/*uint16_t port;*/
|
||||
tmq_commit_cb* commit_cb;
|
||||
};
|
||||
|
||||
struct tmq_t {
|
||||
// conf
|
||||
char groupId[256];
|
||||
char clientId[256];
|
||||
bool autoCommit;
|
||||
int8_t autoCommit;
|
||||
SRWLatch lock;
|
||||
int64_t consumerId;
|
||||
int32_t epoch;
|
||||
int32_t resetOffsetCfg;
|
||||
int64_t status;
|
||||
tsem_t rspSem;
|
||||
STscObj* pTscObj;
|
||||
|
@ -79,7 +80,6 @@ typedef struct {
|
|||
// statistics
|
||||
int64_t pollCnt;
|
||||
// offset
|
||||
int64_t committedOffset;
|
||||
int64_t currentOffset;
|
||||
// connection info
|
||||
int32_t vgId;
|
||||
|
@ -115,21 +115,17 @@ typedef struct {
|
|||
} SMqConsumeCbParam;
|
||||
|
||||
typedef struct {
|
||||
tmq_t* tmq;
|
||||
SMqClientVg* pVg;
|
||||
int32_t async;
|
||||
tsem_t rspSem;
|
||||
} SMqCommitCbParam;
|
||||
|
||||
typedef struct {
|
||||
tmq_t* tmq;
|
||||
tmq_t* tmq;
|
||||
/*SMqClientVg* pVg;*/
|
||||
int32_t async;
|
||||
tsem_t rspSem;
|
||||
tmq_resp_err_t rspErr;
|
||||
} SMqResetOffsetParam;
|
||||
} SMqCommitCbParam;
|
||||
|
||||
tmq_conf_t* tmq_conf_new() {
|
||||
tmq_conf_t* conf = calloc(1, sizeof(tmq_conf_t));
|
||||
conf->auto_commit = false;
|
||||
conf->resetOffset = TMQ_CONF__RESET_OFFSET__LATEST;
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
@ -157,6 +153,20 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
|
|||
return TMQ_CONF_INVALID;
|
||||
}
|
||||
}
|
||||
if (strcmp(key, "auto.offset.reset") == 0) {
|
||||
if (strcmp(value, "none") == 0) {
|
||||
conf->resetOffset = TMQ_CONF__RESET_OFFSET__NONE;
|
||||
return TMQ_CONF_OK;
|
||||
} else if (strcmp(value, "earliest") == 0) {
|
||||
conf->resetOffset = TMQ_CONF__RESET_OFFSET__EARLIEAST;
|
||||
return TMQ_CONF_OK;
|
||||
} else if (strcmp(value, "latest") == 0) {
|
||||
conf->resetOffset = TMQ_CONF__RESET_OFFSET__LATEST;
|
||||
return TMQ_CONF_OK;
|
||||
} else {
|
||||
return TMQ_CONF_INVALID;
|
||||
}
|
||||
}
|
||||
return TMQ_CONF_UNKNOWN;
|
||||
}
|
||||
|
||||
|
@ -190,14 +200,12 @@ int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
if (pParam->tmq->commit_cb) {
|
||||
pParam->tmq->commit_cb(pParam->tmq, rspErr, NULL, NULL);
|
||||
}
|
||||
if (!pParam->async) tsem_post(&pParam->rspSem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tmqResetOffsetCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||
SMqResetOffsetParam* pParam = (SMqResetOffsetParam*)param;
|
||||
pParam->rspErr = code;
|
||||
tsem_post(&pParam->rspSem);
|
||||
if (!pParam->async)
|
||||
tsem_post(&pParam->rspSem);
|
||||
else {
|
||||
tsem_destroy(&pParam->rspSem);
|
||||
free(param);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -216,6 +224,7 @@ tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errs
|
|||
strcpy(pTmq->groupId, conf->groupId);
|
||||
pTmq->autoCommit = conf->auto_commit;
|
||||
pTmq->commit_cb = conf->commit_cb;
|
||||
pTmq->resetOffsetCfg = conf->resetOffset;
|
||||
|
||||
tsem_init(&pTmq->rspSem, 0, 0);
|
||||
pTmq->consumerId = generateRequestId() & (((uint64_t)-1) >> 1);
|
||||
|
@ -223,18 +232,40 @@ tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errs
|
|||
return pTmq;
|
||||
}
|
||||
|
||||
tmq_resp_err_t tmq_reset_offset(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets) {
|
||||
SRequestObj* pRequest = NULL;
|
||||
tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, int32_t async) {
|
||||
// TODO: add read write lock
|
||||
SRequestObj* pRequest = NULL;
|
||||
tmq_resp_err_t resp = TMQ_RESP_ERR__SUCCESS;
|
||||
// build msg
|
||||
// send to mnode
|
||||
SMqCMResetOffsetReq req;
|
||||
req.num = offsets->cnt;
|
||||
req.offsets = (SMqOffset*)offsets->elems;
|
||||
SMqCMCommitOffsetReq req;
|
||||
SArray* pArray = NULL;
|
||||
|
||||
if (offsets == NULL) {
|
||||
pArray = taosArrayInit(0, sizeof(SMqOffset));
|
||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
||||
SMqOffset offset;
|
||||
strcpy(offset.topicName, pTopic->topicName);
|
||||
strcpy(offset.cgroup, tmq->groupId);
|
||||
offset.vgId = pVg->vgId;
|
||||
offset.offset = pVg->currentOffset;
|
||||
taosArrayPush(pArray, &offset);
|
||||
}
|
||||
}
|
||||
req.num = pArray->size;
|
||||
req.offsets = pArray->pData;
|
||||
} else {
|
||||
req.num = offsets->cnt;
|
||||
req.offsets = (SMqOffset*)offsets->elems;
|
||||
}
|
||||
|
||||
SCoder encoder;
|
||||
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER);
|
||||
tEncodeSMqCMResetOffsetReq(&encoder, &req);
|
||||
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
||||
int32_t tlen = encoder.pos;
|
||||
void* buf = malloc(tlen);
|
||||
if (buf == NULL) {
|
||||
|
@ -244,32 +275,41 @@ tmq_resp_err_t tmq_reset_offset(tmq_t* tmq, const tmq_topic_vgroup_list_t* offse
|
|||
tCoderClear(&encoder);
|
||||
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, tlen, TD_ENCODER);
|
||||
tEncodeSMqCMResetOffsetReq(&encoder, &req);
|
||||
tEncodeSMqCMCommitOffsetReq(&encoder, &req);
|
||||
tCoderClear(&encoder);
|
||||
|
||||
pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_MND_RESET_OFFSET);
|
||||
pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_MND_MQ_COMMIT_OFFSET);
|
||||
if (pRequest == NULL) {
|
||||
tscError("failed to malloc request");
|
||||
}
|
||||
|
||||
SMqResetOffsetParam param = {0};
|
||||
tsem_init(¶m.rspSem, 0, 0);
|
||||
param.tmq = tmq;
|
||||
SMqCommitCbParam* pParam = malloc(sizeof(SMqCommitCbParam));
|
||||
if (pParam == NULL) {
|
||||
return -1;
|
||||
}
|
||||
pParam->tmq = tmq;
|
||||
tsem_init(&pParam->rspSem, 0, 0);
|
||||
|
||||
pRequest->body.requestMsg = (SDataBuf){.pData = buf, .len = tlen};
|
||||
|
||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
||||
sendInfo->param = ¶m;
|
||||
sendInfo->fp = tmqResetOffsetCb;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqCommitCb;
|
||||
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
int64_t transporterId = 0;
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo);
|
||||
|
||||
tsem_wait(¶m.rspSem);
|
||||
tsem_destroy(¶m.rspSem);
|
||||
if (!async) {
|
||||
tsem_wait(&pParam->rspSem);
|
||||
resp = pParam->rspErr;
|
||||
}
|
||||
|
||||
return param.rspErr;
|
||||
if (pArray) {
|
||||
taosArrayDestroy(pArray);
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
|
||||
|
@ -641,8 +681,7 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
// clang-format off
|
||||
SMqClientVg clientVg = {
|
||||
.pollCnt = 0,
|
||||
.committedOffset = -1,
|
||||
.currentOffset = -1,
|
||||
.currentOffset = pVgEp->offset,
|
||||
.vgId = pVgEp->vgId,
|
||||
.epSet = pVgEp->epSet
|
||||
};
|
||||
|
@ -708,23 +747,51 @@ END:
|
|||
return 0;
|
||||
}
|
||||
|
||||
SMqConsumeReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blocking_time, int32_t type, SMqClientTopic* pTopic,
|
||||
SMqClientVg* pVg) {
|
||||
tmq_resp_err_t tmq_seek(tmq_t* tmq, const tmq_topic_vgroup_t* offset) {
|
||||
const SMqOffset* pOffset = &offset->offset;
|
||||
if (strcmp(pOffset->cgroup, tmq->groupId) != 0) {
|
||||
return TMQ_RESP_ERR__FAIL;
|
||||
}
|
||||
int32_t sz = taosArrayGetSize(tmq->clientTopics);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqClientTopic* clientTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
if (strcmp(clientTopic->topicName, pOffset->topicName) == 0) {
|
||||
int32_t vgSz = taosArrayGetSize(clientTopic->vgs);
|
||||
for (int32_t j = 0; j < vgSz; j++) {
|
||||
SMqClientVg* pVg = taosArrayGet(clientTopic->vgs, j);
|
||||
if (pVg->vgId == pOffset->vgId) {
|
||||
pVg->currentOffset = pOffset->offset;
|
||||
return TMQ_RESP_ERR__SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return TMQ_RESP_ERR__FAIL;
|
||||
}
|
||||
|
||||
SMqConsumeReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blocking_time, SMqClientTopic* pTopic, SMqClientVg* pVg) {
|
||||
int64_t reqOffset;
|
||||
if (pVg->currentOffset >= 0) {
|
||||
reqOffset = pVg->currentOffset;
|
||||
} else {
|
||||
if (tmq->resetOffsetCfg == TMQ_CONF__RESET_OFFSET__NONE) {
|
||||
tscError("unable to poll since no committed offset but reset offset is set to none");
|
||||
return NULL;
|
||||
}
|
||||
reqOffset = tmq->resetOffsetCfg;
|
||||
}
|
||||
|
||||
SMqConsumeReq* pReq = malloc(sizeof(SMqConsumeReq));
|
||||
if (pReq == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
pReq->reqType = type;
|
||||
|
||||
strcpy(pReq->topic, pTopic->topicName);
|
||||
pReq->blockingTime = blocking_time;
|
||||
pReq->consumerId = tmq->consumerId;
|
||||
strcpy(pReq->cgroup, tmq->groupId);
|
||||
|
||||
if (type == TMQ_REQ_TYPE_COMMIT_ONLY) {
|
||||
pReq->offset = pVg->currentOffset;
|
||||
} else {
|
||||
pReq->offset = pVg->currentOffset + 1;
|
||||
}
|
||||
pReq->blockingTime = blocking_time;
|
||||
pReq->consumerId = tmq->consumerId;
|
||||
pReq->currentOffset = reqOffset;
|
||||
|
||||
pReq->head.vgId = htonl(pVg->vgId);
|
||||
pReq->head.contLen = htonl(sizeof(SMqConsumeReq));
|
||||
|
@ -743,13 +810,13 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
|||
|
||||
if (taosArrayGetSize(tmq->clientTopics) == 0) {
|
||||
tscDebug("consumer:%ld poll but not assigned", tmq->consumerId);
|
||||
printf("over1\n");
|
||||
/*printf("over1\n");*/
|
||||
usleep(blocking_time * 1000);
|
||||
return NULL;
|
||||
}
|
||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, tmq->nextTopicIdx);
|
||||
if (taosArrayGetSize(pTopic->vgs) == 0) {
|
||||
printf("over2\n");
|
||||
/*printf("over2\n");*/
|
||||
usleep(blocking_time * 1000);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -760,8 +827,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
|||
pTopic->nextVgIdx = (pTopic->nextVgIdx + 1) % taosArrayGetSize(pTopic->vgs);
|
||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, pTopic->nextVgIdx);
|
||||
/*printf("consume vg %d, offset %ld\n", pVg->vgId, pVg->currentOffset);*/
|
||||
int32_t reqType = tmq->autoCommit ? TMQ_REQ_TYPE_CONSUME_AND_COMMIT : TMQ_REQ_TYPE_CONSUME_ONLY;
|
||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, blocking_time, reqType, pTopic, pVg);
|
||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, blocking_time, pTopic, pVg);
|
||||
if (pReq == NULL) {
|
||||
ASSERT(false);
|
||||
usleep(blocking_time * 1000);
|
||||
|
@ -821,6 +887,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
|||
/*return pRequest;*/
|
||||
}
|
||||
|
||||
#if 0
|
||||
tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_vgroup_list, int32_t async) {
|
||||
if (tmq_topic_vgroup_list != NULL) {
|
||||
// TODO
|
||||
|
@ -831,7 +898,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_v
|
|||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||
SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j);
|
||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, 0, TMQ_REQ_TYPE_COMMIT_ONLY, pTopic, pVg);
|
||||
SMqConsumeReq* pReq = tmqBuildConsumeReqImpl(tmq, 0, pTopic, pVg);
|
||||
|
||||
SRequestObj* pRequest = createRequest(tmq->pTscObj, NULL, NULL, TDMT_VND_CONSUME);
|
||||
pRequest->body.requestMsg = (SDataBuf){.pData = pReq, .len = sizeof(SMqConsumeReq)};
|
||||
|
@ -858,6 +925,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* tmq_topic_v
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void tmq_message_destroy(tmq_message_t* tmq_message) {
|
||||
if (tmq_message == NULL) return;
|
||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
TEST(testCase, driverInit_Test) {
|
||||
taosInitGlobalCfg();
|
||||
// taosInitGlobalCfg();
|
||||
// taos_init();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
TEST(testCase, driverInit_Test) {
|
||||
taosInitGlobalCfg();
|
||||
// taosInitGlobalCfg();
|
||||
// taos_init();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "tdataformat.h"
|
||||
#include "ulog.h"
|
||||
#include "talgo.h"
|
||||
#include "tcoding.h"
|
||||
#include "wchar.h"
|
||||
#include "tarray.h"
|
||||
#include "tlog.h"
|
||||
|
||||
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
||||
#if 0
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,46 +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 "os.h"
|
||||
#include "ulog.h"
|
||||
#include "tglobal.h"
|
||||
#include "tconfig.h"
|
||||
#include "tutil.h"
|
||||
|
||||
/**
|
||||
* In some Linux systems, setLocale(LC_CTYPE, "") may return NULL, in which case the launch of
|
||||
* both the TDengine Server and the Client may be interrupted.
|
||||
*
|
||||
* In case that the setLocale failed to be executed, the right charset needs to be set.
|
||||
*/
|
||||
void tsSetLocale() {
|
||||
char *locale = setlocale(LC_CTYPE, tsLocale);
|
||||
|
||||
// default locale or user specified locale is not valid, abort launch
|
||||
if (locale == NULL) {
|
||||
uError("Invalid locale:%s, please set the valid locale in config file", tsLocale);
|
||||
}
|
||||
|
||||
if (strlen(tsCharset) == 0) {
|
||||
uError("failed to get charset, please set the valid charset in config file");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!taosValidateEncodec(tsCharset)) {
|
||||
uError("Invalid charset:%s, please set the valid charset in config file", tsCharset);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
|
@ -285,7 +285,7 @@ int32_t tDeserializeSClientHbBatchRsp(void *buf, int32_t bufLen, SClientHbBatchR
|
|||
int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||
int32_t tlen = 0;
|
||||
|
||||
tlen += taosEncodeFixedU64(buf, pReq->ver);
|
||||
tlen += taosEncodeFixedI64(buf, pReq->ver);
|
||||
tlen += taosEncodeString(buf, pReq->name);
|
||||
tlen += taosEncodeFixedU32(buf, pReq->ttl);
|
||||
tlen += taosEncodeFixedU32(buf, pReq->keep);
|
||||
|
@ -330,7 +330,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
|||
}
|
||||
|
||||
void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||
buf = taosDecodeFixedU64(buf, &(pReq->ver));
|
||||
buf = taosDecodeFixedI64(buf, &(pReq->ver));
|
||||
buf = taosDecodeString(buf, &(pReq->name));
|
||||
buf = taosDecodeFixedU32(buf, &(pReq->ttl));
|
||||
buf = taosDecodeFixedU32(buf, &(pReq->keep));
|
||||
|
@ -380,7 +380,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
|||
int32_t tSerializeSVCreateTbBatchReq(void **buf, SVCreateTbBatchReq *pReq) {
|
||||
int32_t tlen = 0;
|
||||
|
||||
tlen += taosEncodeFixedU64(buf, pReq->ver);
|
||||
tlen += taosEncodeFixedI64(buf, pReq->ver);
|
||||
tlen += taosEncodeFixedU32(buf, taosArrayGetSize(pReq->pArray));
|
||||
for (size_t i = 0; i < taosArrayGetSize(pReq->pArray); i++) {
|
||||
SVCreateTbReq *pCreateTbReq = taosArrayGet(pReq->pArray, i);
|
||||
|
@ -393,7 +393,7 @@ int32_t tSerializeSVCreateTbBatchReq(void **buf, SVCreateTbBatchReq *pReq) {
|
|||
void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
|
||||
uint32_t nsize = 0;
|
||||
|
||||
buf = taosDecodeFixedU64(buf, &pReq->ver);
|
||||
buf = taosDecodeFixedI64(buf, &pReq->ver);
|
||||
buf = taosDecodeFixedU32(buf, &nsize);
|
||||
pReq->pArray = taosArrayInit(nsize, sizeof(SVCreateTbReq));
|
||||
for (size_t i = 0; i < nsize; i++) {
|
||||
|
@ -407,14 +407,14 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
|
|||
|
||||
int32_t tSerializeSVDropTbReq(void **buf, SVDropTbReq *pReq) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedU64(buf, pReq->ver);
|
||||
tlen += taosEncodeFixedI64(buf, pReq->ver);
|
||||
tlen += taosEncodeString(buf, pReq->name);
|
||||
tlen += taosEncodeFixedU8(buf, pReq->type);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
void *tDeserializeSVDropTbReq(void *buf, SVDropTbReq *pReq) {
|
||||
buf = taosDecodeFixedU64(buf, &pReq->ver);
|
||||
buf = taosDecodeFixedI64(buf, &pReq->ver);
|
||||
buf = taosDecodeString(buf, &pReq->name);
|
||||
buf = taosDecodeFixedU8(buf, &pReq->type);
|
||||
return buf;
|
||||
|
@ -1393,7 +1393,7 @@ int32_t tSerializeSDropDbRsp(void *buf, int32_t bufLen, SDropDbRsp *pRsp) {
|
|||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pRsp->db) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pRsp->uid) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pRsp->uid) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -1407,7 +1407,7 @@ int32_t tDeserializeSDropDbRsp(void *buf, int32_t bufLen, SDropDbRsp *pRsp) {
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pRsp->db) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pRsp->uid) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pRsp->uid) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tCoderClear(&decoder);
|
||||
|
@ -1468,7 +1468,7 @@ int32_t tDeserializeSSyncDbReq(void *buf, int32_t bufLen, SSyncDbReq *pReq) {
|
|||
|
||||
static int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, SUseDbRsp *pRsp) {
|
||||
if (tEncodeCStr(pEncoder, pRsp->db) < 0) return -1;
|
||||
if (tEncodeU64(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->vgNum) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pRsp->hashMethod) < 0) return -1;
|
||||
|
@ -1518,7 +1518,7 @@ int32_t tSerializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pRsp
|
|||
|
||||
int32_t tDeserializeSUseDbRspImp(SCoder *pDecoder, SUseDbRsp *pRsp) {
|
||||
if (tDecodeCStrTo(pDecoder, pRsp->db) < 0) return -1;
|
||||
if (tDecodeU64(pDecoder, &pRsp->uid) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pRsp->uid) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->vgVersion) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->vgNum) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pRsp->hashMethod) < 0) return -1;
|
||||
|
@ -1661,7 +1661,7 @@ static int32_t tEncodeSTableMetaRsp(SCoder *pEncoder, STableMetaRsp *pRsp) {
|
|||
if (tEncodeCStr(pEncoder, pRsp->tbName) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pRsp->stbName) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pRsp->dbFName) < 0) return -1;
|
||||
if (tEncodeU64(pEncoder, pRsp->dbId) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pRsp->dbId) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->numOfTags) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->numOfColumns) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pRsp->precision) < 0) return -1;
|
||||
|
@ -1684,7 +1684,7 @@ static int32_t tDecodeSTableMetaRsp(SCoder *pDecoder, STableMetaRsp *pRsp) {
|
|||
if (tDecodeCStrTo(pDecoder, pRsp->tbName) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pRsp->stbName) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pRsp->dbFName) < 0) return -1;
|
||||
if (tDecodeU64(pDecoder, &pRsp->dbId) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pRsp->dbId) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->numOfTags) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->numOfColumns) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pRsp->precision) < 0) return -1;
|
||||
|
@ -2093,7 +2093,7 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
|||
if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->dbUid) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->cacheBlockSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1;
|
||||
|
@ -2133,7 +2133,7 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
|||
if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->dbUid) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->cacheBlockSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1;
|
||||
|
@ -2171,7 +2171,7 @@ int32_t tSerializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq)
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->dbUid) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -2187,7 +2187,7 @@ int32_t tDeserializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq
|
|||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->dbUid) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
|
@ -2356,35 +2356,7 @@ int32_t tDecodeSMqOffset(SCoder *decoder, SMqOffset *pOffset) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSMqVgOffsets(SCoder *encoder, const SMqVgOffsets *pOffsets) {
|
||||
if (tStartEncode(encoder) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pOffsets->vgId) < 0) return -1;
|
||||
int32_t sz = taosArrayGetSize(pOffsets->offsets);
|
||||
if (tEncodeI32(encoder, sz) < 0) return -1;
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqOffset *offset = taosArrayGet(pOffsets->offsets, i);
|
||||
if (tEncodeSMqOffset(encoder, offset) < 0) return -1;
|
||||
}
|
||||
tEndEncode(encoder);
|
||||
return encoder->pos;
|
||||
}
|
||||
|
||||
int32_t tDecodeSMqVgOffsets(SCoder *decoder, SMqVgOffsets *pOffsets) {
|
||||
int32_t sz;
|
||||
if (tStartDecode(decoder) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pOffsets->vgId) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &sz) < 0) return -1;
|
||||
pOffsets->offsets = taosArrayInit(sz, sizeof(SMqOffset));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqOffset offset;
|
||||
if (tDecodeSMqOffset(decoder, &offset) < 0) return -1;
|
||||
taosArrayPush(pOffsets->offsets, &offset);
|
||||
}
|
||||
tEndDecode(decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tEncodeSMqCMResetOffsetReq(SCoder *encoder, const SMqCMResetOffsetReq *pReq) {
|
||||
int32_t tEncodeSMqCMCommitOffsetReq(SCoder *encoder, const SMqCMCommitOffsetReq *pReq) {
|
||||
if (tStartEncode(encoder) < 0) return -1;
|
||||
if (tEncodeI32(encoder, pReq->num) < 0) return -1;
|
||||
for (int32_t i = 0; i < pReq->num; i++) {
|
||||
|
@ -2394,7 +2366,7 @@ int32_t tEncodeSMqCMResetOffsetReq(SCoder *encoder, const SMqCMResetOffsetReq *p
|
|||
return encoder->pos;
|
||||
}
|
||||
|
||||
int32_t tDecodeSMqCMResetOffsetReq(SCoder *decoder, SMqCMResetOffsetReq *pReq) {
|
||||
int32_t tDecodeSMqCMCommitOffsetReq(SCoder *decoder, SMqCMCommitOffsetReq *pReq) {
|
||||
if (tStartDecode(decoder) < 0) return -1;
|
||||
if (tDecodeI32(decoder, &pReq->num) < 0) return -1;
|
||||
pReq->offsets = TCODER_MALLOC(pReq->num * sizeof(SMqOffset), decoder);
|
||||
|
@ -2405,23 +2377,3 @@ int32_t tDecodeSMqCMResetOffsetReq(SCoder *decoder, SMqCMResetOffsetReq *pReq) {
|
|||
tEndDecode(decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t tEncodeSMqMVResetOffsetReq(SCoder *encoder, const SMqMVResetOffsetReq *pReq) {
|
||||
if (tEncodeI64(encoder, pReq->leftForVer) < 0) return -1;
|
||||
for (int32_t i = 0; i < pReq->num; i++) {
|
||||
tEncodeSMqOffset(encoder, &pReq->offsets[i]);
|
||||
}
|
||||
return encoder->pos;
|
||||
}
|
||||
|
||||
int32_t tDecodeSMqMVResetOffsetReq(SCoder *decoder, SMqMVResetOffsetReq *pReq) {
|
||||
if (tDecodeI32(decoder, &pReq->num) < 0) return -1;
|
||||
pReq->offsets = TCODER_MALLOC(pReq->num * sizeof(SMqOffset), decoder);
|
||||
if (pReq->offsets == NULL) return -1;
|
||||
for (int32_t i = 0; i < pReq->num; i++) {
|
||||
tDecodeSMqOffset(decoder, &pReq->offsets[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,7 +31,7 @@ SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFil
|
|||
}
|
||||
|
||||
assert(src->filterstr == 0 || src->filterstr == 1);
|
||||
assert(!(src->lowerRelOptr == TSDB_RELATION_INVALID && src->upperRelOptr == TSDB_RELATION_INVALID));
|
||||
assert(!(src->lowerRelOptr == 0 && src->upperRelOptr == 0));
|
||||
|
||||
return pFilter;
|
||||
}
|
||||
|
|
|
@ -1,67 +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 "os.h"
|
||||
#include "ulog.h"
|
||||
#include "tglobal.h"
|
||||
#include "tconfig.h"
|
||||
#include "tutil.h"
|
||||
|
||||
// TODO refactor to set the tz value through parameter
|
||||
void tsSetTimeZone() {
|
||||
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
|
||||
if (cfg_timezone != NULL) {
|
||||
uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
|
||||
}
|
||||
|
||||
#ifdef WINDOWS
|
||||
char winStr[TSDB_LOCALE_LEN * 2];
|
||||
sprintf(winStr, "TZ=%s", tsTimezone);
|
||||
putenv(winStr);
|
||||
#else
|
||||
setenv("TZ", tsTimezone, 1);
|
||||
#endif
|
||||
tzset();
|
||||
|
||||
/*
|
||||
* get CURRENT time zone.
|
||||
* system current time zone is affected by daylight saving time(DST)
|
||||
*
|
||||
* e.g., the local time zone of London in DST is GMT+01:00,
|
||||
* otherwise is GMT+00:00
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER >= 1900
|
||||
// see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019
|
||||
int64_t timezone = _timezone;
|
||||
int32_t daylight = _daylight;
|
||||
char **tzname = _tzname;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR);
|
||||
tz += daylight;
|
||||
|
||||
/*
|
||||
* format:
|
||||
* (CST, +0800)
|
||||
* (BST, +0100)
|
||||
*/
|
||||
sprintf(tsTimezone, "(%s, %s%02d00)", tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
|
||||
tsDaylight = daylight;
|
||||
|
||||
uInfo("timezone format changed to %s", tsTimezone);
|
||||
}
|
|
@ -24,8 +24,9 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
|
|||
pTSBuf->autoDelete = autoDelete;
|
||||
|
||||
taosGetTmpfilePath(tsTempDir, "join", pTSBuf->path);
|
||||
pTSBuf->f = fopen(pTSBuf->path, "wb+");
|
||||
if (pTSBuf->f == NULL) {
|
||||
// pTSBuf->pFile = fopen(pTSBuf->path, "wb+");
|
||||
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (pTSBuf->pFile == NULL) {
|
||||
free(pTSBuf);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -60,8 +61,9 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
|||
|
||||
tstrncpy(pTSBuf->path, path, sizeof(pTSBuf->path));
|
||||
|
||||
pTSBuf->f = fopen(pTSBuf->path, "rb+");
|
||||
if (pTSBuf->f == NULL) {
|
||||
// pTSBuf->pFile = fopen(pTSBuf->path, "rb+");
|
||||
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_WRITE | TD_FILE_READ);
|
||||
if (pTSBuf->pFile == NULL) {
|
||||
free(pTSBuf);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -72,9 +74,9 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
|||
|
||||
// validate the file magic number
|
||||
STSBufFileHeader header = {0};
|
||||
int32_t ret = fseek(pTSBuf->f, 0, SEEK_SET);
|
||||
int32_t ret = taosLSeekFile(pTSBuf->pFile, 0, SEEK_SET);
|
||||
UNUSED(ret);
|
||||
size_t sz = fread(&header, 1, sizeof(STSBufFileHeader), pTSBuf->f);
|
||||
size_t sz = taosReadFile(pTSBuf->pFile, &header, sizeof(STSBufFileHeader));
|
||||
UNUSED(sz);
|
||||
|
||||
// invalid file
|
||||
|
@ -112,8 +114,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//int64_t pos = ftell(pTSBuf->f); //pos not used
|
||||
sz = fread(buf, infoSize, 1, pTSBuf->f);
|
||||
//int64_t pos = ftell(pTSBuf->pFile); //pos not used
|
||||
sz = taosReadFile(pTSBuf->pFile, buf, infoSize);
|
||||
UNUSED(sz);
|
||||
|
||||
// the length value for each vnode is not kept in file, so does not set the length value
|
||||
|
@ -123,22 +125,22 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
|||
}
|
||||
free(buf);
|
||||
|
||||
ret = fseek(pTSBuf->f, 0, SEEK_END);
|
||||
ret = taosLSeekFile(pTSBuf->pFile, 0, SEEK_END);
|
||||
UNUSED(ret);
|
||||
|
||||
struct stat fileStat;
|
||||
if (fstat(fileno(pTSBuf->f), &fileStat) != 0) {
|
||||
int64_t file_size;
|
||||
if (taosFStatFile(pTSBuf->pFile, &file_size, NULL) != 0) {
|
||||
tsBufDestroy(pTSBuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pTSBuf->fileSize = (uint32_t)fileStat.st_size;
|
||||
pTSBuf->fileSize = (uint32_t)file_size;
|
||||
tsBufResetPos(pTSBuf);
|
||||
|
||||
// ascending by default
|
||||
pTSBuf->cur.order = TSDB_ORDER_ASC;
|
||||
|
||||
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfGroups:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
|
||||
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfGroups:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->pFile),
|
||||
// pTSBuf->fileSize, pTSBuf->numOfGroups, pTSBuf->autoDelete);
|
||||
|
||||
return pTSBuf;
|
||||
|
@ -156,7 +158,7 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
|
|||
tfree(pTSBuf->block.payload);
|
||||
|
||||
if (!pTSBuf->remainOpen) {
|
||||
fclose(pTSBuf->f);
|
||||
taosCloseFile(&pTSBuf->pFile);
|
||||
}
|
||||
|
||||
if (pTSBuf->autoDelete) {
|
||||
|
@ -253,7 +255,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
|
|||
tsCompressTimestamp(pTsData->rawBuf, pTsData->len, pTsData->len/TSDB_KEYSIZE, pBlock->payload, pTsData->allocSize,
|
||||
TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize);
|
||||
|
||||
int64_t r = fseek(pTSBuf->f, pTSBuf->fileSize, SEEK_SET);
|
||||
int64_t r = taosLSeekFile(pTSBuf->pFile, pTSBuf->fileSize, SEEK_SET);
|
||||
assert(r == 0);
|
||||
|
||||
/*
|
||||
|
@ -264,30 +266,30 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
|
|||
* both side has the compressed length is used to support load data forwards/backwords.
|
||||
*/
|
||||
int32_t metaLen = 0;
|
||||
metaLen += (int32_t)fwrite(&pBlock->tag.nType, 1, sizeof(pBlock->tag.nType), pTSBuf->f);
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &pBlock->tag.nType, sizeof(pBlock->tag.nType));
|
||||
|
||||
int32_t trueLen = pBlock->tag.nLen;
|
||||
if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
metaLen += (int32_t)fwrite(&pBlock->tag.nLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f);
|
||||
metaLen += (int32_t)fwrite(pBlock->tag.pz, 1, (size_t)pBlock->tag.nLen, pTSBuf->f);
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &pBlock->tag.nLen, sizeof(pBlock->tag.nLen));
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, pBlock->tag.pz, (size_t)pBlock->tag.nLen);
|
||||
} else if (pBlock->tag.nType == TSDB_DATA_TYPE_FLOAT) {
|
||||
metaLen += (int32_t)fwrite(&pBlock->tag.nLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f);
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &pBlock->tag.nLen, sizeof(pBlock->tag.nLen));
|
||||
float tfloat = (float)pBlock->tag.d;
|
||||
metaLen += (int32_t)fwrite(&tfloat, 1, (size_t) pBlock->tag.nLen, pTSBuf->f);
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &tfloat, (size_t) pBlock->tag.nLen);
|
||||
} else if (pBlock->tag.nType != TSDB_DATA_TYPE_NULL) {
|
||||
metaLen += (int32_t)fwrite(&pBlock->tag.nLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f);
|
||||
metaLen += (int32_t)fwrite(&pBlock->tag.i, 1, (size_t) pBlock->tag.nLen, pTSBuf->f);
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &pBlock->tag.nLen, sizeof(pBlock->tag.nLen));
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &pBlock->tag.i, (size_t) pBlock->tag.nLen);
|
||||
} else {
|
||||
trueLen = 0;
|
||||
metaLen += (int32_t)fwrite(&trueLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f);
|
||||
metaLen += (int32_t)taosWriteFile(pTSBuf->pFile, &trueLen, sizeof(pBlock->tag.nLen));
|
||||
}
|
||||
|
||||
fwrite(&pBlock->numOfElem, sizeof(pBlock->numOfElem), 1, pTSBuf->f);
|
||||
fwrite(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
||||
fwrite(pBlock->payload, (size_t)pBlock->compLen, 1, pTSBuf->f);
|
||||
fwrite(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
||||
taosWriteFile(pTSBuf->pFile, &pBlock->numOfElem, sizeof(pBlock->numOfElem));
|
||||
taosWriteFile(pTSBuf->pFile, &pBlock->compLen, sizeof(pBlock->compLen));
|
||||
taosWriteFile(pTSBuf->pFile, pBlock->payload, (size_t)pBlock->compLen);
|
||||
taosWriteFile(pTSBuf->pFile, &pBlock->compLen, sizeof(pBlock->compLen));
|
||||
|
||||
metaLen += (int32_t) fwrite(&trueLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f);
|
||||
metaLen += (int32_t) taosWriteFile(pTSBuf->pFile, &trueLen, sizeof(pBlock->tag.nLen));
|
||||
assert(metaLen == getTagAreaLength(&pBlock->tag));
|
||||
|
||||
int32_t blockSize = metaLen + sizeof(pBlock->numOfElem) + sizeof(pBlock->compLen) * 2 + pBlock->compLen;
|
||||
|
@ -332,20 +334,20 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
|
|||
* the end of each comp data block
|
||||
*/
|
||||
int32_t prev = -(int32_t) (sizeof(pBlock->padding) + sizeof(pBlock->tag.nLen));
|
||||
int32_t ret = fseek(pTSBuf->f, prev, SEEK_CUR);
|
||||
size_t sz = fread(&pBlock->padding, 1, sizeof(pBlock->padding), pTSBuf->f);
|
||||
sz = fread(&pBlock->tag.nLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f);
|
||||
int32_t ret = taosLSeekFile(pTSBuf->pFile, prev, SEEK_CUR);
|
||||
size_t sz = taosReadFile(pTSBuf->pFile, &pBlock->padding, sizeof(pBlock->padding));
|
||||
sz = taosReadFile(pTSBuf->pFile, &pBlock->tag.nLen, sizeof(pBlock->tag.nLen));
|
||||
UNUSED(sz);
|
||||
|
||||
pBlock->compLen = pBlock->padding;
|
||||
|
||||
offset = pBlock->compLen + sizeof(pBlock->compLen) * 2 + sizeof(pBlock->numOfElem) + getTagAreaLength(&pBlock->tag);
|
||||
ret = fseek(pTSBuf->f, -offset, SEEK_CUR);
|
||||
ret = taosLSeekFile(pTSBuf->pFile, -offset, SEEK_CUR);
|
||||
UNUSED(ret);
|
||||
}
|
||||
|
||||
int32_t ret = fread(&pBlock->tag.nType, sizeof(pBlock->tag.nType), 1, pTSBuf->f);
|
||||
ret = fread(&pBlock->tag.nLen, sizeof(pBlock->tag.nLen), 1, pTSBuf->f);
|
||||
int32_t ret = taosReadFile(pTSBuf->pFile, &pBlock->tag.nType, sizeof(pBlock->tag.nType));
|
||||
ret = taosReadFile(pTSBuf->pFile, &pBlock->tag.nLen, sizeof(pBlock->tag.nLen));
|
||||
|
||||
// NOTE: mix types tags are not supported
|
||||
size_t sz = 0;
|
||||
|
@ -356,23 +358,23 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
|
|||
memset(tp, 0, pBlock->tag.nLen + 1);
|
||||
pBlock->tag.pz = tp;
|
||||
|
||||
sz = fread(pBlock->tag.pz, (size_t)pBlock->tag.nLen, 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, pBlock->tag.pz, (size_t)pBlock->tag.nLen);
|
||||
UNUSED(sz);
|
||||
} else if (pBlock->tag.nType == TSDB_DATA_TYPE_FLOAT) {
|
||||
float tfloat = 0;
|
||||
sz = fread(&tfloat, (size_t) pBlock->tag.nLen, 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, &tfloat, (size_t) pBlock->tag.nLen);
|
||||
pBlock->tag.d = (double)tfloat;
|
||||
UNUSED(sz);
|
||||
} else if (pBlock->tag.nType != TSDB_DATA_TYPE_NULL) { //TODO check the return value
|
||||
sz = fread(&pBlock->tag.i, (size_t) pBlock->tag.nLen, 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, &pBlock->tag.i, (size_t) pBlock->tag.nLen);
|
||||
UNUSED(sz);
|
||||
}
|
||||
|
||||
sz = fread(&pBlock->numOfElem, sizeof(pBlock->numOfElem), 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, &pBlock->numOfElem, sizeof(pBlock->numOfElem));
|
||||
UNUSED(sz);
|
||||
sz = fread(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, &pBlock->compLen, sizeof(pBlock->compLen));
|
||||
UNUSED(sz);
|
||||
sz = fread(pBlock->payload, (size_t)pBlock->compLen, 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, pBlock->payload, (size_t)pBlock->compLen);
|
||||
|
||||
if (decomp) {
|
||||
pTSBuf->tsData.len =
|
||||
|
@ -381,11 +383,11 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
|
|||
}
|
||||
|
||||
// read the comp length at the length of comp block
|
||||
sz = fread(&pBlock->padding, sizeof(pBlock->padding), 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, &pBlock->padding, sizeof(pBlock->padding));
|
||||
assert(pBlock->padding == pBlock->compLen);
|
||||
|
||||
int32_t n = 0;
|
||||
sz = fread(&n, sizeof(pBlock->tag.nLen), 1, pTSBuf->f);
|
||||
sz = taosReadFile(pTSBuf->pFile, &n, sizeof(pBlock->tag.nLen));
|
||||
if (pBlock->tag.nType == TSDB_DATA_TYPE_NULL) {
|
||||
assert(n == 0);
|
||||
} else {
|
||||
|
@ -396,7 +398,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
|
|||
|
||||
// for backwards traverse, set the start position at the end of previous block
|
||||
if (order == TSDB_ORDER_DESC) {
|
||||
int32_t r = fseek(pTSBuf->f, -offset, SEEK_CUR);
|
||||
int32_t r = taosLSeekFile(pTSBuf->pFile, -offset, SEEK_CUR);
|
||||
UNUSED(r);
|
||||
}
|
||||
|
||||
|
@ -512,7 +514,7 @@ static int32_t tsBufFindGroupById(STSGroupBlockInfoEx* pGroupInfoEx, int32_t num
|
|||
|
||||
// todo opt performance by cache blocks info
|
||||
static int32_t tsBufFindBlock(STSBuf* pTSBuf, STSGroupBlockInfo* pBlockInfo, int32_t blockIndex) {
|
||||
if (fseek(pTSBuf->f, pBlockInfo->offset, SEEK_SET) != 0) {
|
||||
if (taosLSeekFile(pTSBuf->pFile, pBlockInfo->offset, SEEK_SET) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -531,7 +533,7 @@ static int32_t tsBufFindBlock(STSBuf* pTSBuf, STSGroupBlockInfo* pBlockInfo, int
|
|||
STSBlock* pBlock = &pTSBuf->block;
|
||||
int32_t compBlockSize =
|
||||
pBlock->compLen + sizeof(pBlock->compLen) * 2 + sizeof(pBlock->numOfElem) + getTagAreaLength(&pBlock->tag);
|
||||
int32_t ret = fseek(pTSBuf->f, -compBlockSize, SEEK_CUR);
|
||||
int32_t ret = taosLSeekFile(pTSBuf->pFile, -compBlockSize, SEEK_CUR);
|
||||
UNUSED(ret);
|
||||
}
|
||||
|
||||
|
@ -548,7 +550,7 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSGroupBlockInfo* pBlockInfo
|
|||
offset = pBlockInfo->offset + pBlockInfo->compLen;
|
||||
}
|
||||
|
||||
if (fseek(pTSBuf->f, (int32_t)offset, SEEK_SET) != 0) {
|
||||
if (taosLSeekFile(pTSBuf->pFile, (int32_t)offset, SEEK_SET) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -618,11 +620,11 @@ static int32_t doUpdateGroupInfo(STSBuf* pTSBuf, int64_t offset, STSGroupBlockIn
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (fseek(pTSBuf->f, (int32_t)offset, SEEK_SET) != 0) {
|
||||
if (taosLSeekFile(pTSBuf->pFile, (int32_t)offset, SEEK_SET) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwrite(pVInfo, sizeof(STSGroupBlockInfo), 1, pTSBuf->f);
|
||||
taosWriteFile(pTSBuf->pFile, pVInfo, sizeof(STSGroupBlockInfo));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -636,19 +638,19 @@ STSGroupBlockInfo* tsBufGetGroupBlockInfo(STSBuf* pTSBuf, int32_t id) {
|
|||
}
|
||||
|
||||
int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) {
|
||||
if ((pTSBuf->f == NULL) || pHeader == NULL || pHeader->numOfGroup == 0 || pHeader->magic != TS_COMP_FILE_MAGIC) {
|
||||
if ((pTSBuf->pFile == NULL) || pHeader == NULL || pHeader->numOfGroup == 0 || pHeader->magic != TS_COMP_FILE_MAGIC) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(pHeader->tsOrder == TSDB_ORDER_ASC || pHeader->tsOrder == TSDB_ORDER_DESC);
|
||||
|
||||
int32_t r = fseek(pTSBuf->f, 0, SEEK_SET);
|
||||
int32_t r = taosLSeekFile(pTSBuf->pFile, 0, SEEK_SET);
|
||||
if (r != 0) {
|
||||
// qError("fseek failed, errno:%d", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t ws = fwrite(pHeader, sizeof(STSBufFileHeader), 1, pTSBuf->f);
|
||||
size_t ws = taosWriteFile(pTSBuf->pFile, pHeader, sizeof(STSBufFileHeader));
|
||||
if (ws != 1) {
|
||||
// qError("ts update header fwrite failed, size:%d, expected size:%d", (int32_t)ws, (int32_t)sizeof(STSBufFileHeader));
|
||||
return -1;
|
||||
|
@ -823,12 +825,12 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
|
|||
pBlockInfoEx->info.id = id;
|
||||
}
|
||||
|
||||
int32_t r = fseek(pDestBuf->f, 0, SEEK_END);
|
||||
int32_t r = taosLSeekFile(pDestBuf->pFile, 0, SEEK_END);
|
||||
assert(r == 0);
|
||||
|
||||
int64_t offset = getDataStartOffset();
|
||||
int32_t size = (int32_t)pSrcBuf->fileSize - (int32_t)offset;
|
||||
int64_t written = taosFSendFile(pDestBuf->f, pSrcBuf->f, &offset, size);
|
||||
int64_t written = taosFSendFile(pDestBuf->pFile, pSrcBuf->pFile, &offset, size);
|
||||
|
||||
if (written == -1 || written != size) {
|
||||
return -1;
|
||||
|
@ -839,17 +841,18 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
|
|||
int32_t oldSize = pDestBuf->fileSize;
|
||||
|
||||
// file meta data may be cached, close and reopen the file for accurate file size.
|
||||
fclose(pDestBuf->f);
|
||||
pDestBuf->f = fopen(pDestBuf->path, "rb+");
|
||||
if (pDestBuf->f == NULL) {
|
||||
taosCloseFile(&pDestBuf->pFile);
|
||||
// pDestBuf->pFile = fopen(pDestBuf->path, "rb+");
|
||||
pDestBuf->pFile = taosOpenFile(pDestBuf->path, TD_FILE_WRITE | TD_FILE_READ);
|
||||
if (pDestBuf->pFile == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct stat fileStat;
|
||||
if (fstat(fileno(pDestBuf->f), &fileStat) != 0) {
|
||||
int64_t file_size;
|
||||
if (taosFStatFile(pDestBuf->pFile, &file_size, NULL) != 0) {
|
||||
return -1;
|
||||
}
|
||||
pDestBuf->fileSize = (uint32_t)fileStat.st_size;
|
||||
pDestBuf->fileSize = (uint32_t)file_size;
|
||||
|
||||
assert(pDestBuf->fileSize == oldSize + size);
|
||||
|
||||
|
@ -868,13 +871,13 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
|
|||
// update prev vnode length info in file
|
||||
TSBufUpdateGroupInfo(pTSBuf, pTSBuf->numOfGroups - 1, pBlockInfo);
|
||||
|
||||
int32_t ret = fseek(pTSBuf->f, pBlockInfo->offset, SEEK_SET);
|
||||
int32_t ret = taosLSeekFile(pTSBuf->pFile, pBlockInfo->offset, SEEK_SET);
|
||||
if (ret == -1) {
|
||||
// qError("fseek failed, errno:%d", errno);
|
||||
tsBufDestroy(pTSBuf);
|
||||
return NULL;
|
||||
}
|
||||
size_t sz = fwrite((void*)pData, 1, len, pTSBuf->f);
|
||||
size_t sz = taosWriteFile(pTSBuf->pFile, (void*)pData, len);
|
||||
if (sz != len) {
|
||||
// qError("ts data fwrite failed, write size:%d, expected size:%d", (int32_t)sz, len);
|
||||
tsBufDestroy(pTSBuf);
|
||||
|
@ -893,7 +896,7 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
|
|||
}
|
||||
|
||||
// TODO taosFsync??
|
||||
// if (taosFsync(fileno(pTSBuf->f)) == -1) {
|
||||
// if (taosFsync(fileno(pTSBuf->pFile)) == -1) {
|
||||
//// qError("fsync failed, errno:%d", errno);
|
||||
// tsBufDestroy(pTSBuf);
|
||||
// return NULL;
|
||||
|
@ -1071,15 +1074,15 @@ int32_t dumpFileBlockByGroupId(STSBuf* pTSBuf, int32_t groupIndex, void* buf, in
|
|||
*len = 0;
|
||||
*numOfBlocks = 0;
|
||||
|
||||
if (fseek(pTSBuf->f, pBlockInfo->offset, SEEK_SET) != 0) {
|
||||
int code = TAOS_SYSTEM_ERROR(ferror(pTSBuf->f));
|
||||
if (taosLSeekFile(pTSBuf->pFile, pBlockInfo->offset, SEEK_SET) != 0) {
|
||||
int code = TAOS_SYSTEM_ERROR(taosEOFFile(pTSBuf->pFile));
|
||||
// qError("%p: fseek failed: %s", pSql, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
size_t s = fread(buf, 1, pBlockInfo->compLen, pTSBuf->f);
|
||||
size_t s = taosReadFile(pTSBuf->pFile, buf, pBlockInfo->compLen);
|
||||
if (s != pBlockInfo->compLen) {
|
||||
int code = TAOS_SYSTEM_ERROR(ferror(pTSBuf->f));
|
||||
int code = TAOS_SYSTEM_ERROR(taosEOFFile(pTSBuf->pFile));
|
||||
// tscError("%p: fread didn't return expected data: %s", pSql, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -585,7 +585,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
|
|||
}
|
||||
|
||||
void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type) {
|
||||
if (optr == TSDB_BINARY_OP_ADD) {
|
||||
if (optr == OP_TYPE_ADD) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
*((int8_t *)dst) = GET_INT8_VAL(s1) + GET_INT8_VAL(s2);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
aux_source_directory(src DAEMON_SRC)
|
||||
add_executable(taosd ${DAEMON_SRC})
|
||||
target_link_libraries(
|
||||
|
||||
target_include_directories(
|
||||
taosd
|
||||
PUBLIC dnode
|
||||
PUBLIC util
|
||||
PUBLIC os
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
target_link_libraries(taosd dnode util os)
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
/*
|
||||
* 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_DMN_INT_H_
|
||||
#define _TD_DMN_INT_H_
|
||||
|
||||
#include "tconfig.h"
|
||||
#include "dnode.h"
|
||||
#include "taoserror.h"
|
||||
#include "tglobal.h"
|
||||
#include "tlog.h"
|
||||
#include "version.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
SDnodeObjCfg dmnGetObjCfg();
|
||||
|
||||
void dmnDumpCfg();
|
||||
void dmnPrintVersion();
|
||||
void dmnGenerateGrant();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_DMN_INT_H_*/
|
|
@ -1,218 +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 "dnode.h"
|
||||
#include "os.h"
|
||||
#include "tconfig.h"
|
||||
#include "tglobal.h"
|
||||
#include "tnote.h"
|
||||
#include "ulog.h"
|
||||
|
||||
static struct {
|
||||
bool stop;
|
||||
bool dumpConfig;
|
||||
bool generateGrant;
|
||||
bool printAuth;
|
||||
bool printVersion;
|
||||
char configDir[PATH_MAX];
|
||||
} dmn = {0};
|
||||
|
||||
void dmnSigintHandle(int signum, void *info, void *ctx) {
|
||||
uInfo("singal:%d is received", signum);
|
||||
dmn.stop = true;
|
||||
}
|
||||
|
||||
void dmnSetSignalHandle() {
|
||||
taosSetSignal(SIGTERM, dmnSigintHandle);
|
||||
taosSetSignal(SIGHUP, dmnSigintHandle);
|
||||
taosSetSignal(SIGINT, dmnSigintHandle);
|
||||
taosSetSignal(SIGABRT, dmnSigintHandle);
|
||||
taosSetSignal(SIGBREAK, dmnSigintHandle);
|
||||
}
|
||||
|
||||
int dmnParseOption(int argc, char const *argv[]) {
|
||||
tstrncpy(dmn.configDir, "/etc/taos", PATH_MAX);
|
||||
|
||||
for (int 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(dmn.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) {
|
||||
dmn.dumpConfig = true;
|
||||
} else if (strcmp(argv[i], "-k") == 0) {
|
||||
dmn.generateGrant = true;
|
||||
} else if (strcmp(argv[i], "-A") == 0) {
|
||||
dmn.printAuth = true;
|
||||
} else if (strcmp(argv[i], "-V") == 0) {
|
||||
dmn.printVersion = true;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dmnGenerateGrant() {
|
||||
#if 0
|
||||
grantParseParameter();
|
||||
#endif
|
||||
}
|
||||
|
||||
void dmnPrintVersion() {
|
||||
#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("gitinfoI: %s\n", gitinfoOfInternal);
|
||||
printf("builuInfo: %s\n", buildinfo);
|
||||
}
|
||||
|
||||
int dmnReadConfig(const char *path) {
|
||||
tstrncpy(configDir, dmn.configDir, PATH_MAX);
|
||||
taosInitGlobalCfg();
|
||||
taosReadGlobalLogCfg();
|
||||
|
||||
if (taosMkDir(tsLogDir) != 0) {
|
||||
printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
char temp[PATH_MAX];
|
||||
snprintf(temp, PATH_MAX, "%s/taosdlog", tsLogDir);
|
||||
if (taosInitLog(temp, tsNumOfLogLines, 1) != 0) {
|
||||
printf("failed to init log file\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosInitNotes() != 0) {
|
||||
printf("failed to init log file\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosReadCfgFromFile() != 0) {
|
||||
uError("failed to read config");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosCheckAndPrintCfg() != 0) {
|
||||
uError("failed to check config");
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosSetCoreDump(tsEnableCoreFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dmnDumpConfig() { taosDumpGlobalCfg(); }
|
||||
|
||||
void dmnWaitSignal() {
|
||||
dmnSetSignalHandle();
|
||||
while (!dmn.stop) {
|
||||
taosMsleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
void dnmInitEnvCfg(SDnodeEnvCfg *pCfg) {
|
||||
pCfg->sver = 30000000; // 3.0.0.0
|
||||
pCfg->numOfCores = tsNumOfCores;
|
||||
pCfg->numOfCommitThreads = tsNumOfCommitThreads;
|
||||
pCfg->enableTelem = 0;
|
||||
tstrncpy(pCfg->timezone, tsTimezone, TSDB_TIMEZONE_LEN);
|
||||
tstrncpy(pCfg->locale, tsLocale, TSDB_LOCALE_LEN);
|
||||
tstrncpy(pCfg->charset, tsCharset, TSDB_LOCALE_LEN);
|
||||
tstrncpy(pCfg->buildinfo, buildinfo, 64);
|
||||
tstrncpy(pCfg->gitinfo, gitinfo, 48);
|
||||
}
|
||||
|
||||
void dmnInitObjCfg(SDnodeObjCfg *pCfg) {
|
||||
pCfg->numOfSupportVnodes = tsNumOfSupportVnodes;
|
||||
pCfg->statusInterval = tsStatusInterval;
|
||||
pCfg->numOfThreadsPerCore = tsNumOfThreadsPerCore;
|
||||
pCfg->ratioOfQueryCores = tsRatioOfQueryCores;
|
||||
pCfg->maxShellConns = tsMaxShellConns;
|
||||
pCfg->shellActivityTimer = tsShellActivityTimer;
|
||||
pCfg->serverPort = tsServerPort;
|
||||
tstrncpy(pCfg->dataDir, tsDataDir, TSDB_FILENAME_LEN);
|
||||
tstrncpy(pCfg->localEp, tsLocalEp, TSDB_EP_LEN);
|
||||
tstrncpy(pCfg->localFqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||
tstrncpy(pCfg->firstEp, tsFirst, TSDB_EP_LEN);
|
||||
}
|
||||
|
||||
int dmnRunDnode() {
|
||||
SDnodeEnvCfg envCfg = {0};
|
||||
SDnodeObjCfg objCfg = {0};
|
||||
|
||||
dnmInitEnvCfg(&envCfg);
|
||||
dmnInitObjCfg(&objCfg);
|
||||
|
||||
if (dndInit(&envCfg) != 0) {
|
||||
uInfo("Failed to start TDengine, please check the log at %s", tsLogDir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDnode *pDnode = dndCreate(&objCfg);
|
||||
if (pDnode == NULL) {
|
||||
uInfo("Failed to start TDengine, please check the log at %s", tsLogDir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uInfo("Started TDengine service successfully.");
|
||||
dmnWaitSignal();
|
||||
uInfo("TDengine is shut down!");
|
||||
|
||||
dndClose(pDnode);
|
||||
dndCleanup();
|
||||
taosCloseLog();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
if (dmnParseOption(argc, argv) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dmn.generateGrant) {
|
||||
dmnGenerateGrant();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dmn.printVersion) {
|
||||
dmnPrintVersion();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dmnReadConfig(dmn.configDir) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dmn.dumpConfig) {
|
||||
dmnDumpConfig();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return dmnRunDnode();
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 "dmnInt.h"
|
||||
#include "tconfig.h"
|
||||
|
||||
SDnodeObjCfg dmnGetObjCfg() {
|
||||
SConfig *pCfg = taosGetCfg();
|
||||
SDnodeObjCfg objCfg = {0};
|
||||
|
||||
objCfg.numOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
|
||||
tstrncpy(objCfg.dataDir, cfgGetItem(pCfg, "dataDir")->str, sizeof(objCfg.dataDir));
|
||||
tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp));
|
||||
tstrncpy(objCfg.secondEp, cfgGetItem(pCfg, "secondEp")->str, sizeof(objCfg.firstEp));
|
||||
objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn));
|
||||
snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort);
|
||||
objCfg.pDisks = tsDiskCfg;
|
||||
objCfg.numOfDisks = tsDiskCfgNum;
|
||||
return objCfg;
|
||||
}
|
||||
|
||||
void dmnDumpCfg() {
|
||||
SConfig *pCfg = taosGetCfg();
|
||||
cfgDumpCfg(pCfg, 0, 1);
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* 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 "dmnInt.h"
|
||||
|
||||
static struct {
|
||||
bool stop;
|
||||
bool dumpConfig;
|
||||
bool generateGrant;
|
||||
bool printAuth;
|
||||
bool printVersion;
|
||||
char envFile[PATH_MAX];
|
||||
char apolloUrl[PATH_MAX];
|
||||
} dmn = {0};
|
||||
|
||||
static void dmnSigintHandle(int signum, void *info, void *ctx) {
|
||||
uInfo("singal:%d is received", signum);
|
||||
dmn.stop = true;
|
||||
}
|
||||
|
||||
static void dmnSetSignalHandle() {
|
||||
taosSetSignal(SIGTERM, dmnSigintHandle);
|
||||
taosSetSignal(SIGHUP, dmnSigintHandle);
|
||||
taosSetSignal(SIGINT, dmnSigintHandle);
|
||||
taosSetSignal(SIGABRT, dmnSigintHandle);
|
||||
taosSetSignal(SIGBREAK, dmnSigintHandle);
|
||||
}
|
||||
|
||||
static void dmnWaitSignal() {
|
||||
dmnSetSignalHandle();
|
||||
while (!dmn.stop) {
|
||||
taosMsleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t dmnParseOption(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) {
|
||||
dmn.dumpConfig = true;
|
||||
} else if (strcmp(argv[i], "-k") == 0) {
|
||||
dmn.generateGrant = true;
|
||||
} else if (strcmp(argv[i], "-V") == 0) {
|
||||
dmn.printVersion = true;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t dmnRunDnode() {
|
||||
if (dndInit() != 0) {
|
||||
uInfo("Failed to start TDengine, please check the log");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDnodeObjCfg objCfg = dmnGetObjCfg();
|
||||
SDnode *pDnode = dndCreate(&objCfg);
|
||||
if (pDnode == NULL) {
|
||||
uInfo("Failed to start TDengine, please check the log");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uInfo("Started TDengine service successfully.");
|
||||
dmnWaitSignal();
|
||||
uInfo("TDengine is shut down!");
|
||||
|
||||
dndClose(pDnode);
|
||||
dndCleanup();
|
||||
taosCloseLog();
|
||||
taosCleanupCfg();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
if (dmnParseOption(argc, argv) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dmn.generateGrant) {
|
||||
dmnGenerateGrant();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dmn.printVersion) {
|
||||
dmnPrintVersion();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (taosCreateLog("taosdlog", 1, configDir, dmn.envFile, dmn.apolloUrl, NULL, 0) != 0) {
|
||||
uInfo("Failed to start TDengine since read config error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosInitCfg(configDir, dmn.envFile, dmn.apolloUrl, NULL, 0) != 0) {
|
||||
uInfo("Failed to start TDengine since read config error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dmn.dumpConfig) {
|
||||
dmnDumpCfg();
|
||||
taosCleanupCfg();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return dmnRunDnode();
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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 "dmnInt.h"
|
||||
|
||||
void dmnGenerateGrant() {
|
||||
#if 0
|
||||
grantParseParameter();
|
||||
#endif
|
||||
}
|
||||
|
||||
void dmnPrintVersion() {
|
||||
#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("gitinfoI: %s\n", gitinfoOfInternal);
|
||||
printf("builuInfo: %s\n", buildinfo);
|
||||
}
|
|
@ -124,9 +124,8 @@ typedef struct {
|
|||
typedef struct SDnode {
|
||||
EStat stat;
|
||||
SDnodeObjCfg cfg;
|
||||
SDnodeEnvCfg env;
|
||||
SDnodeDir dir;
|
||||
FileFd lockFd;
|
||||
TdFilePtr pLockFile;
|
||||
SDnodeMgmt dmgmt;
|
||||
SMnodeMgmt mmgmt;
|
||||
SQnodeMgmt qmgmt;
|
||||
|
@ -138,11 +137,6 @@ typedef struct SDnode {
|
|||
SStartupReq startup;
|
||||
} SDnode;
|
||||
|
||||
typedef struct {
|
||||
int8_t once;
|
||||
SDnodeEnvCfg cfg;
|
||||
} SDnodeEnv;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@ extern "C" {
|
|||
#include "tthread.h"
|
||||
#include "ttime.h"
|
||||
#include "tworker.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
#include "dnode.h"
|
||||
|
||||
|
|
|
@ -62,14 +62,15 @@ static int32_t dndReadBnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "r");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
dDebug("file %s not exist", file);
|
||||
code = 0;
|
||||
goto PRASE_BNODE_OVER;
|
||||
}
|
||||
|
||||
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
||||
if (len <= 0) {
|
||||
dError("failed to read %s since content is null", file);
|
||||
goto PRASE_BNODE_OVER;
|
||||
|
@ -102,7 +103,7 @@ static int32_t dndReadBnodeFile(SDnode *pDnode) {
|
|||
PRASE_BNODE_OVER:
|
||||
if (content != NULL) free(content);
|
||||
if (root != NULL) cJSON_Delete(root);
|
||||
if (fp != NULL) fclose(fp);
|
||||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
terrno = code;
|
||||
return code;
|
||||
|
@ -114,8 +115,9 @@ static int32_t dndWriteBnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "w");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "w");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR;
|
||||
dError("failed to write %s since %s", file, terrstr());
|
||||
return -1;
|
||||
|
@ -130,9 +132,9 @@ static int32_t dndWriteBnodeFile(SDnode *pDnode) {
|
|||
len += snprintf(content + len, maxLen - len, " \"dropped\": %d\n", pMgmt->dropped);
|
||||
len += snprintf(content + len, maxLen - len, "}\n");
|
||||
|
||||
fwrite(content, 1, len, fp);
|
||||
taosFsyncFile(fileno(fp));
|
||||
fclose(fp);
|
||||
taosWriteFile(pFile, content, len);
|
||||
taosFsyncFile(pFile);
|
||||
taosCloseFile(&pFile);
|
||||
free(content);
|
||||
|
||||
char realfile[PATH_MAX + 20];
|
||||
|
@ -179,7 +181,7 @@ static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) {
|
|||
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||
pOption->clusterId = dndGetClusterId(pDnode);
|
||||
pOption->sver = pDnode->env.sver;
|
||||
pOption->sver = tsVersion;
|
||||
}
|
||||
|
||||
static int32_t dndOpenBnode(SDnode *pDnode) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "tfs.h"
|
||||
#include "wal.h"
|
||||
|
||||
static SDnodeEnv dndEnv = {0};
|
||||
static int8_t once = DND_ENV_INIT;
|
||||
|
||||
EStat dndGetStat(SDnode *pDnode) { return pDnode->stat; }
|
||||
|
||||
|
@ -59,31 +59,31 @@ void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) {
|
|||
pStartup->finished = (dndGetStat(pDnode) == DND_STAT_RUNNING);
|
||||
}
|
||||
|
||||
static FileFd dndCheckRunning(char *dataDir) {
|
||||
static TdFilePtr dndCheckRunning(char *dataDir) {
|
||||
char filepath[PATH_MAX] = {0};
|
||||
snprintf(filepath, sizeof(filepath), "%s/.running", dataDir);
|
||||
|
||||
FileFd fd = taosOpenFileCreateWriteTrunc(filepath);
|
||||
if (fd < 0) {
|
||||
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to lock file:%s since %s, quit", filepath, terrstr());
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t ret = taosLockFile(fd);
|
||||
int32_t ret = taosLockFile(pFile);
|
||||
if (ret != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to lock file:%s since %s, quit", filepath, terrstr());
|
||||
taosCloseFile(fd);
|
||||
return -1;
|
||||
taosCloseFile(&pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fd;
|
||||
return pFile;
|
||||
}
|
||||
|
||||
static int32_t dndCreateImp(SDnode *pDnode, SDnodeObjCfg *pCfg) {
|
||||
pDnode->lockFd = dndCheckRunning(pCfg->dataDir);
|
||||
if (pDnode->lockFd < 0) {
|
||||
static int32_t dndInitDir(SDnode *pDnode, SDnodeObjCfg *pCfg) {
|
||||
pDnode->pLockFile = dndCheckRunning(pCfg->dataDir);
|
||||
if (pDnode->pLockFile == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,6 @@ static int32_t dndCreateImp(SDnode *pDnode, SDnodeObjCfg *pCfg) {
|
|||
}
|
||||
|
||||
memcpy(&pDnode->cfg, pCfg, sizeof(SDnodeObjCfg));
|
||||
memcpy(&pDnode->env, &dndEnv.cfg, sizeof(SDnodeEnvCfg));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -148,10 +147,10 @@ static void dndCloseImp(SDnode *pDnode) {
|
|||
tfree(pDnode->dir.snode);
|
||||
tfree(pDnode->dir.bnode);
|
||||
|
||||
if (pDnode->lockFd >= 0) {
|
||||
taosUnLockFile(pDnode->lockFd);
|
||||
taosCloseFile(pDnode->lockFd);
|
||||
pDnode->lockFd = 0;
|
||||
if (pDnode->pLockFile != NULL) {
|
||||
taosUnLockFile(pDnode->pLockFile);
|
||||
taosCloseFile(&pDnode->pLockFile);
|
||||
pDnode->pLockFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,7 +166,7 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) {
|
|||
|
||||
dndSetStat(pDnode, DND_STAT_INIT);
|
||||
|
||||
if (dndCreateImp(pDnode, pCfg) != 0) {
|
||||
if (dndInitDir(pDnode, pCfg) != 0) {
|
||||
dError("failed to init dnode dir since %s", terrstr());
|
||||
dndClose(pDnode);
|
||||
return NULL;
|
||||
|
@ -177,7 +176,14 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) {
|
|||
tstrncpy(dCfg.dir, pDnode->cfg.dataDir, TSDB_FILENAME_LEN);
|
||||
dCfg.level = 0;
|
||||
dCfg.primary = 1;
|
||||
pDnode->pTfs = tfsOpen(&dCfg, 1);
|
||||
SDiskCfg *pDisks = pDnode->cfg.pDisks;
|
||||
int32_t numOfDisks = pDnode->cfg.numOfDisks;
|
||||
if (numOfDisks <= 0 || pDisks == NULL) {
|
||||
pDisks = &dCfg;
|
||||
numOfDisks = 1;
|
||||
}
|
||||
|
||||
pDnode->pTfs = tfsOpen(pDisks, numOfDisks);
|
||||
if (pDnode->pTfs == NULL) {
|
||||
dError("failed to init tfs since %s", terrstr());
|
||||
dndClose(pDnode);
|
||||
|
@ -259,8 +265,8 @@ void dndClose(SDnode *pDnode) {
|
|||
dInfo("dnode object is closed, data:%p", pDnode);
|
||||
}
|
||||
|
||||
int32_t dndInit(const SDnodeEnvCfg *pCfg) {
|
||||
if (atomic_val_compare_exchange_8(&dndEnv.once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
||||
int32_t dndInit() {
|
||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
||||
terrno = TSDB_CODE_REPEAT_INIT;
|
||||
dError("failed to init dnode env since %s", terrstr());
|
||||
return -1;
|
||||
|
@ -283,11 +289,8 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) {
|
|||
}
|
||||
|
||||
SVnodeOpt vnodeOpt = {
|
||||
.sver = pCfg->sver,
|
||||
.timezone = pCfg->timezone,
|
||||
.locale = pCfg->locale,
|
||||
.charset = pCfg->charset,
|
||||
.nthreads = pCfg->numOfCommitThreads,
|
||||
.sver = tsVersion,
|
||||
.nthreads = tsNumOfCommitThreads,
|
||||
.putReqToVQueryQFp = dndPutReqToVQueryQ,
|
||||
.sendReqToDnodeFp = dndSendReqToDnode
|
||||
};
|
||||
|
@ -298,13 +301,12 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
memcpy(&dndEnv.cfg, pCfg, sizeof(SDnodeEnvCfg));
|
||||
dInfo("dnode env is initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dndCleanup() {
|
||||
if (atomic_val_compare_exchange_8(&dndEnv.once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
||||
dError("dnode env is already cleaned up");
|
||||
return;
|
||||
}
|
||||
|
@ -325,18 +327,6 @@ void taosGetDisk() {
|
|||
SDiskSize diskSize = tfsGetSize(pTfs);
|
||||
|
||||
tfsUpdateSize(&fsMeta);
|
||||
tsTotalDataDirGB = (float)(fsMeta.total / unit);
|
||||
tsUsedDataDirGB = (float)(fsMeta.used / unit);
|
||||
tsAvailDataDirGB = (float)(fsMeta.avail / unit);
|
||||
|
||||
if (taosGetDiskSize(tsLogDir, &diskSize) == 0) {
|
||||
tsTotalLogDirGB = (float)(diskSize.total / unit);
|
||||
tsAvailLogDirGB = (float)(diskSize.avail / unit);
|
||||
}
|
||||
|
||||
if (taosGetDiskSize(tsTempDir, &diskSize) == 0) {
|
||||
tsTotalTmpDirGB = (float)(diskSize.total / unit);
|
||||
tsAvailTmpDirectorySpace = (float)(diskSize.avail / unit);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -185,16 +185,16 @@ static int32_t dndReadDnodes(SDnode *pDnode) {
|
|||
int32_t maxLen = 256 * 1024;
|
||||
char *content = calloc(1, maxLen + 1);
|
||||
cJSON *root = NULL;
|
||||
FILE *fp = NULL;
|
||||
|
||||
fp = fopen(pMgmt->file, "r");
|
||||
if (fp == NULL) {
|
||||
// fp = fopen(pMgmt->file, "r");
|
||||
TdFilePtr pFile = taosOpenFile(pMgmt->file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
dDebug("file %s not exist", pMgmt->file);
|
||||
code = 0;
|
||||
goto PRASE_DNODE_OVER;
|
||||
}
|
||||
|
||||
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
||||
if (len <= 0) {
|
||||
dError("failed to read %s since content is null", pMgmt->file);
|
||||
goto PRASE_DNODE_OVER;
|
||||
|
@ -286,7 +286,7 @@ static int32_t dndReadDnodes(SDnode *pDnode) {
|
|||
PRASE_DNODE_OVER:
|
||||
if (content != NULL) free(content);
|
||||
if (root != NULL) cJSON_Delete(root);
|
||||
if (fp != NULL) fclose(fp);
|
||||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
if (dndIsEpChanged(pDnode, pMgmt->dnodeId, pDnode->cfg.localEp)) {
|
||||
dError("localEp %s different with %s and need reconfigured", pDnode->cfg.localEp, pMgmt->file);
|
||||
|
@ -309,8 +309,9 @@ PRASE_DNODE_OVER:
|
|||
static int32_t dndWriteDnodes(SDnode *pDnode) {
|
||||
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
||||
|
||||
FILE *fp = fopen(pMgmt->file, "w");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(pMgmt->file, "w");
|
||||
TdFilePtr pFile = taosOpenFile(pMgmt->file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
dError("failed to write %s since %s", pMgmt->file, strerror(errno));
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
@ -341,9 +342,9 @@ static int32_t dndWriteDnodes(SDnode *pDnode) {
|
|||
}
|
||||
len += snprintf(content + len, maxLen - len, "}\n");
|
||||
|
||||
fwrite(content, 1, len, fp);
|
||||
taosFsyncFile(fileno(fp));
|
||||
fclose(fp);
|
||||
taosWriteFile(pFile, content, len);
|
||||
taosFsyncFile(pFile);
|
||||
taosCloseFile(&pFile);
|
||||
free(content);
|
||||
terrno = 0;
|
||||
|
||||
|
@ -357,23 +358,23 @@ void dndSendStatusReq(SDnode *pDnode) {
|
|||
|
||||
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
||||
taosRLockLatch(&pMgmt->latch);
|
||||
req.sver = pDnode->env.sver;
|
||||
req.sver = tsVersion;
|
||||
req.dver = pMgmt->dver;
|
||||
req.dnodeId = pMgmt->dnodeId;
|
||||
req.clusterId = pMgmt->clusterId;
|
||||
req.rebootTime = pMgmt->rebootTime;
|
||||
req.updateTime = pMgmt->updateTime;
|
||||
req.numOfCores = pDnode->env.numOfCores;
|
||||
req.numOfCores = tsNumOfCores;
|
||||
req.numOfSupportVnodes = pDnode->cfg.numOfSupportVnodes;
|
||||
memcpy(req.dnodeEp, pDnode->cfg.localEp, TSDB_EP_LEN);
|
||||
|
||||
req.clusterCfg.statusInterval = pDnode->cfg.statusInterval;
|
||||
req.clusterCfg.statusInterval = tsStatusInterval;
|
||||
req.clusterCfg.checkTime = 0;
|
||||
char timestr[32] = "1970-01-01 00:00:00.00";
|
||||
(void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||
memcpy(req.clusterCfg.timezone, pDnode->env.timezone, TSDB_TIMEZONE_LEN);
|
||||
memcpy(req.clusterCfg.locale, pDnode->env.locale, TSDB_LOCALE_LEN);
|
||||
memcpy(req.clusterCfg.charset, pDnode->env.charset, TSDB_LOCALE_LEN);
|
||||
memcpy(req.clusterCfg.timezone, tsTimezone, TD_TIMEZONE_LEN);
|
||||
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);
|
||||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||
taosRUnLockLatch(&pMgmt->latch);
|
||||
|
||||
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
||||
|
@ -475,7 +476,7 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
|||
static void *dnodeThreadRoutine(void *param) {
|
||||
SDnode *pDnode = param;
|
||||
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
||||
int32_t ms = pDnode->cfg.statusInterval * 1000;
|
||||
int32_t ms = tsStatusInterval * 1000;
|
||||
|
||||
setThreadName("dnode-hb");
|
||||
|
||||
|
|
|
@ -63,14 +63,15 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/mnode.json", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "r");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
dDebug("file %s not exist", file);
|
||||
code = 0;
|
||||
goto PRASE_MNODE_OVER;
|
||||
}
|
||||
|
||||
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
||||
if (len <= 0) {
|
||||
dError("failed to read %s since content is null", file);
|
||||
goto PRASE_MNODE_OVER;
|
||||
|
@ -143,7 +144,7 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) {
|
|||
PRASE_MNODE_OVER:
|
||||
if (content != NULL) free(content);
|
||||
if (root != NULL) cJSON_Delete(root);
|
||||
if (fp != NULL) fclose(fp);
|
||||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
terrno = code;
|
||||
return code;
|
||||
|
@ -155,8 +156,9 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/mnode.json.bak", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "w");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "w");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR;
|
||||
dError("failed to write %s since %s", file, terrstr());
|
||||
return -1;
|
||||
|
@ -184,9 +186,9 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
|
|||
}
|
||||
len += snprintf(content + len, maxLen - len, "}\n");
|
||||
|
||||
fwrite(content, 1, len, fp);
|
||||
taosFsyncFile(fileno(fp));
|
||||
fclose(fp);
|
||||
taosWriteFile(pFile, content, len);
|
||||
taosFsyncFile(pFile);
|
||||
taosCloseFile(&pFile);
|
||||
free(content);
|
||||
|
||||
char realfile[PATH_MAX + 20];
|
||||
|
@ -273,15 +275,6 @@ static void dndInitMnodeOption(SDnode *pDnode, SMnodeOpt *pOption) {
|
|||
pOption->putReqToMReadQFp = dndPutMsgToMReadQ;
|
||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||
pOption->clusterId = dndGetClusterId(pDnode);
|
||||
pOption->cfg.sver = pDnode->env.sver;
|
||||
pOption->cfg.enableTelem = pDnode->env.enableTelem;
|
||||
pOption->cfg.statusInterval = pDnode->cfg.statusInterval;
|
||||
pOption->cfg.shellActivityTimer = pDnode->cfg.shellActivityTimer;
|
||||
pOption->cfg.timezone = pDnode->env.timezone;
|
||||
pOption->cfg.charset = pDnode->env.charset;
|
||||
pOption->cfg.locale = pDnode->env.locale;
|
||||
pOption->cfg.gitinfo = pDnode->env.gitinfo;
|
||||
pOption->cfg.buildinfo = pDnode->env.buildinfo;
|
||||
}
|
||||
|
||||
static void dndBuildMnodeDeployOption(SDnode *pDnode, SMnodeOpt *pOption) {
|
||||
|
|
|
@ -62,14 +62,15 @@ static int32_t dndReadQnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/qnode.json", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "r");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
dDebug("file %s not exist", file);
|
||||
code = 0;
|
||||
goto PRASE_QNODE_OVER;
|
||||
}
|
||||
|
||||
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
||||
if (len <= 0) {
|
||||
dError("failed to read %s since content is null", file);
|
||||
goto PRASE_QNODE_OVER;
|
||||
|
@ -102,7 +103,7 @@ static int32_t dndReadQnodeFile(SDnode *pDnode) {
|
|||
PRASE_QNODE_OVER:
|
||||
if (content != NULL) free(content);
|
||||
if (root != NULL) cJSON_Delete(root);
|
||||
if (fp != NULL) fclose(fp);
|
||||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
terrno = code;
|
||||
return code;
|
||||
|
@ -114,8 +115,9 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/qnode.json", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "w");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "w");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR;
|
||||
dError("failed to write %s since %s", file, terrstr());
|
||||
return -1;
|
||||
|
@ -130,9 +132,9 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) {
|
|||
len += snprintf(content + len, maxLen - len, " \"dropped\": %d\n", pMgmt->dropped);
|
||||
len += snprintf(content + len, maxLen - len, "}\n");
|
||||
|
||||
fwrite(content, 1, len, fp);
|
||||
taosFsyncFile(fileno(fp));
|
||||
fclose(fp);
|
||||
taosWriteFile(pFile, content, len);
|
||||
taosFsyncFile(pFile);
|
||||
taosCloseFile(&pFile);
|
||||
free(content);
|
||||
|
||||
char realfile[PATH_MAX + 20];
|
||||
|
@ -185,7 +187,7 @@ static void dndBuildQnodeOption(SDnode *pDnode, SQnodeOpt *pOption) {
|
|||
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||
pOption->clusterId = dndGetClusterId(pDnode);
|
||||
pOption->sver = pDnode->env.sver;
|
||||
pOption->sver = tsVersion;
|
||||
}
|
||||
|
||||
static int32_t dndOpenQnode(SDnode *pDnode) {
|
||||
|
|
|
@ -62,14 +62,15 @@ static int32_t dndReadSnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "r");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
dDebug("file %s not exist", file);
|
||||
code = 0;
|
||||
goto PRASE_SNODE_OVER;
|
||||
}
|
||||
|
||||
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
||||
if (len <= 0) {
|
||||
dError("failed to read %s since content is null", file);
|
||||
goto PRASE_SNODE_OVER;
|
||||
|
@ -102,7 +103,7 @@ static int32_t dndReadSnodeFile(SDnode *pDnode) {
|
|||
PRASE_SNODE_OVER:
|
||||
if (content != NULL) free(content);
|
||||
if (root != NULL) cJSON_Delete(root);
|
||||
if (fp != NULL) fclose(fp);
|
||||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
terrno = code;
|
||||
return code;
|
||||
|
@ -114,8 +115,9 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
|
|||
char file[PATH_MAX + 20];
|
||||
snprintf(file, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode);
|
||||
|
||||
FILE *fp = fopen(file, "w");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "w");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR;
|
||||
dError("failed to write %s since %s", file, terrstr());
|
||||
return -1;
|
||||
|
@ -130,9 +132,9 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
|
|||
len += snprintf(content + len, maxLen - len, " \"dropped\": %d\n", pMgmt->dropped);
|
||||
len += snprintf(content + len, maxLen - len, "}\n");
|
||||
|
||||
fwrite(content, 1, len, fp);
|
||||
taosFsyncFile(fileno(fp));
|
||||
fclose(fp);
|
||||
taosWriteFile(pFile, content, len);
|
||||
taosFsyncFile(pFile);
|
||||
taosCloseFile(&pFile);
|
||||
free(content);
|
||||
|
||||
char realfile[PATH_MAX + 20];
|
||||
|
@ -179,7 +181,7 @@ static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
|
|||
pOption->sendRedirectRspFp = dndSendRedirectRsp;
|
||||
pOption->dnodeId = dndGetDnodeId(pDnode);
|
||||
pOption->clusterId = dndGetClusterId(pDnode);
|
||||
pOption->sver = pDnode->env.sver;
|
||||
pOption->sver = tsVersion;
|
||||
}
|
||||
|
||||
static int32_t dndOpenSnode(SDnode *pDnode) {
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include "dndMnode.h"
|
||||
#include "dndVnodes.h"
|
||||
|
||||
#define INTERNAL_USER "_dnd"
|
||||
#define INTERNAL_CKEY "_key"
|
||||
#define INTERNAL_USER "_dnd"
|
||||
#define INTERNAL_CKEY "_key"
|
||||
#define INTERNAL_SECRET "_pwd"
|
||||
|
||||
static void dndInitMsgFp(STransMgmt *pMgmt) {
|
||||
|
@ -113,6 +113,7 @@ static void dndInitMsgFp(STransMgmt *pMgmt) {
|
|||
pMgmt->msgFp[TMSG_INDEX(TDMT_MND_ALTER_TOPIC)] = dndProcessMnodeWriteMsg;
|
||||
pMgmt->msgFp[TMSG_INDEX(TDMT_MND_DROP_TOPIC)] = dndProcessMnodeWriteMsg;
|
||||
pMgmt->msgFp[TMSG_INDEX(TDMT_MND_SUBSCRIBE)] = dndProcessMnodeWriteMsg;
|
||||
pMgmt->msgFp[TMSG_INDEX(TDMT_MND_MQ_COMMIT_OFFSET)] = dndProcessMnodeWriteMsg;
|
||||
/*pMgmt->msgFp[TMSG_INDEX(TDMT_VND_SUBSCRIBE_RSP)] = dndProcessMnodeWriteMsg;*/
|
||||
pMgmt->msgFp[TMSG_INDEX(TDMT_VND_MQ_SET_CONN_RSP)] = dndProcessMnodeWriteMsg;
|
||||
pMgmt->msgFp[TMSG_INDEX(TDMT_VND_MQ_REB_RSP)] = dndProcessMnodeWriteMsg;
|
||||
|
@ -155,7 +156,7 @@ static void dndInitMsgFp(STransMgmt *pMgmt) {
|
|||
}
|
||||
|
||||
static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
|
||||
SDnode * pDnode = parent;
|
||||
SDnode *pDnode = parent;
|
||||
STransMgmt *pMgmt = &pDnode->tmgmt;
|
||||
|
||||
tmsg_t msgType = pRsp->msgType;
|
||||
|
@ -188,7 +189,7 @@ static int32_t dndInitClient(SDnode *pDnode) {
|
|||
rpcInit.cfp = dndProcessResponse;
|
||||
rpcInit.sessions = 1024;
|
||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||
rpcInit.idleTime = pDnode->cfg.shellActivityTimer * 1000;
|
||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||
rpcInit.user = INTERNAL_USER;
|
||||
rpcInit.ckey = INTERNAL_CKEY;
|
||||
rpcInit.spi = 1;
|
||||
|
@ -219,7 +220,7 @@ static void dndCleanupClient(SDnode *pDnode) {
|
|||
}
|
||||
|
||||
static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
|
||||
SDnode * pDnode = param;
|
||||
SDnode *pDnode = param;
|
||||
STransMgmt *pMgmt = &pDnode->tmgmt;
|
||||
|
||||
tmsg_t msgType = pReq->msgType;
|
||||
|
@ -313,7 +314,7 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char
|
|||
SAuthReq authReq = {0};
|
||||
tstrncpy(authReq.user, user, TSDB_USER_LEN);
|
||||
int32_t contLen = tSerializeSAuthReq(NULL, 0, &authReq);
|
||||
void * pReq = rpcMallocCont(contLen);
|
||||
void *pReq = rpcMallocCont(contLen);
|
||||
tSerializeSAuthReq(pReq, contLen, &authReq);
|
||||
|
||||
SRpcMsg rpcMsg = {.pCont = pReq, .contLen = contLen, .msgType = TDMT_MND_AUTH, .ahandle = (void *)9528};
|
||||
|
@ -343,7 +344,7 @@ static int32_t dndInitServer(SDnode *pDnode) {
|
|||
STransMgmt *pMgmt = &pDnode->tmgmt;
|
||||
dndInitMsgFp(pMgmt);
|
||||
|
||||
int32_t numOfThreads = (int32_t)((pDnode->env.numOfCores * pDnode->cfg.numOfThreadsPerCore) / 2.0);
|
||||
int32_t numOfThreads = (int32_t)((tsNumOfCores * tsNumOfThreadsPerCore) / 2.0);
|
||||
if (numOfThreads < 1) {
|
||||
numOfThreads = 1;
|
||||
}
|
||||
|
@ -354,9 +355,9 @@ static int32_t dndInitServer(SDnode *pDnode) {
|
|||
rpcInit.label = "D-S";
|
||||
rpcInit.numOfThreads = numOfThreads;
|
||||
rpcInit.cfp = dndProcessRequest;
|
||||
rpcInit.sessions = pDnode->cfg.maxShellConns;
|
||||
rpcInit.sessions = tsMaxShellConns;
|
||||
rpcInit.connType = TAOS_CONN_SERVER;
|
||||
rpcInit.idleTime = pDnode->cfg.shellActivityTimer * 1000;
|
||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||
rpcInit.afp = dndRetrieveUserAuthInfo;
|
||||
rpcInit.parent = pDnode;
|
||||
|
||||
|
|
|
@ -219,14 +219,15 @@ static int32_t dndGetVnodesFromFile(SDnode *pDnode, SWrapperCfg **ppCfgs, int32_
|
|||
|
||||
snprintf(file, PATH_MAX + 20, "%s/vnodes.json", pDnode->dir.vnodes);
|
||||
|
||||
fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
// fp = fopen(file, "r");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
dDebug("file %s not exist", file);
|
||||
code = 0;
|
||||
goto PRASE_VNODE_OVER;
|
||||
}
|
||||
|
||||
len = (int32_t)fread(content, 1, maxLen, fp);
|
||||
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
||||
if (len <= 0) {
|
||||
dError("failed to read %s since content is null", file);
|
||||
goto PRASE_VNODE_OVER;
|
||||
|
@ -304,7 +305,7 @@ static int32_t dndGetVnodesFromFile(SDnode *pDnode, SWrapperCfg **ppCfgs, int32_
|
|||
PRASE_VNODE_OVER:
|
||||
if (content != NULL) free(content);
|
||||
if (root != NULL) cJSON_Delete(root);
|
||||
if (fp != NULL) fclose(fp);
|
||||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -315,8 +316,9 @@ static int32_t dndWriteVnodesToFile(SDnode *pDnode) {
|
|||
snprintf(file, PATH_MAX + 20, "%s/vnodes.json.bak", pDnode->dir.vnodes);
|
||||
snprintf(realfile, PATH_MAX + 20, "%s/vnodes.json", pDnode->dir.vnodes);
|
||||
|
||||
FILE *fp = fopen(file, "w");
|
||||
if (fp == NULL) {
|
||||
// FILE *fp = fopen(file, "w");
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to write %s since %s", file, terrstr());
|
||||
return -1;
|
||||
|
@ -347,9 +349,9 @@ static int32_t dndWriteVnodesToFile(SDnode *pDnode) {
|
|||
len += snprintf(content + len, maxLen - len, " ]\n");
|
||||
len += snprintf(content + len, maxLen - len, "}\n");
|
||||
|
||||
fwrite(content, 1, len, fp);
|
||||
taosFsyncFile(fileno(fp));
|
||||
fclose(fp);
|
||||
taosWriteFile(pFile, content, len);
|
||||
taosFsyncFile(pFile);
|
||||
taosCloseFile(&pFile);
|
||||
free(content);
|
||||
terrno = 0;
|
||||
|
||||
|
@ -421,7 +423,7 @@ static int32_t dndOpenVnodes(SDnode *pDnode) {
|
|||
|
||||
pMgmt->totalVnodes = numOfVnodes;
|
||||
|
||||
int32_t threadNum = pDnode->env.numOfCores;
|
||||
int32_t threadNum = tsNumOfCores;
|
||||
#if 1
|
||||
threadNum = 1;
|
||||
#endif
|
||||
|
@ -874,11 +876,11 @@ static int32_t dndInitVnodeWorkers(SDnode *pDnode) {
|
|||
SVnodesMgmt *pMgmt = &pDnode->vmgmt;
|
||||
|
||||
int32_t maxFetchThreads = 4;
|
||||
int32_t minFetchThreads = TMIN(maxFetchThreads, pDnode->env.numOfCores);
|
||||
int32_t minQueryThreads = TMAX((int32_t)(pDnode->env.numOfCores * pDnode->cfg.ratioOfQueryCores), 1);
|
||||
int32_t minFetchThreads = TMIN(maxFetchThreads, tsNumOfCores);
|
||||
int32_t minQueryThreads = TMAX((int32_t)(tsNumOfCores * tsRatioOfQueryCores), 1);
|
||||
int32_t maxQueryThreads = minQueryThreads;
|
||||
int32_t maxWriteThreads = TMAX(pDnode->env.numOfCores, 1);
|
||||
int32_t maxSyncThreads = TMAX(pDnode->env.numOfCores / 2, 1);
|
||||
int32_t maxWriteThreads = TMAX(tsNumOfCores, 1);
|
||||
int32_t maxSyncThreads = TMAX(tsNumOfCores / 2, 1);
|
||||
|
||||
SQWorkerPool *pQPool = &pMgmt->queryPool;
|
||||
pQPool->name = "vnode-query";
|
||||
|
|
|
@ -20,17 +20,16 @@
|
|||
#include "os.h"
|
||||
|
||||
#include "dnode.h"
|
||||
#include "tconfig.h"
|
||||
#include "tmsg.h"
|
||||
#include "tdataformat.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsg.h"
|
||||
#include "tnote.h"
|
||||
#include "trpc.h"
|
||||
#include "tthread.h"
|
||||
#include "ulog.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "server.h"
|
||||
#include "tlog.h"
|
||||
|
||||
class Testbase {
|
||||
public:
|
||||
|
|
|
@ -24,6 +24,9 @@ static void processClientRsp(void* parent, SRpcMsg* pRsp, SEpSet* pEpSet) {
|
|||
}
|
||||
|
||||
void TestClient::SetRpcRsp(SRpcMsg* rsp) {
|
||||
if (this->pRsp) {
|
||||
free(this->pRsp);
|
||||
}
|
||||
this->pRsp = (SRpcMsg*)calloc(1, sizeof(SRpcMsg));
|
||||
this->pRsp->msgType = rsp->msgType;
|
||||
this->pRsp->code = rsp->code;
|
||||
|
@ -60,7 +63,7 @@ bool TestClient::Init(const char* user, const char* pass, const char* fqdn, uint
|
|||
strcpy(this->user, user);
|
||||
strcpy(this->pass, pass);
|
||||
this->port = port;
|
||||
// this->pRsp = NULL;
|
||||
this->pRsp = NULL;
|
||||
this->DoInit();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -25,11 +25,6 @@ void* serverLoop(void* param) {
|
|||
SDnodeObjCfg TestServer::BuildOption(const char* path, const char* fqdn, uint16_t port, const char* firstEp) {
|
||||
SDnodeObjCfg cfg = {0};
|
||||
cfg.numOfSupportVnodes = 16;
|
||||
cfg.statusInterval = 1;
|
||||
cfg.numOfThreadsPerCore = 1;
|
||||
cfg.ratioOfQueryCores = 1;
|
||||
cfg.maxShellConns = 1000;
|
||||
cfg.shellActivityTimer = 30;
|
||||
cfg.serverPort = port;
|
||||
strcpy(cfg.dataDir, path);
|
||||
snprintf(cfg.localEp, TSDB_EP_LEN, "%s:%u", fqdn, port);
|
||||
|
|
|
@ -28,25 +28,19 @@ void Testbase::InitLog(const char* path) {
|
|||
wDebugFlag = 0;
|
||||
sDebugFlag = 0;
|
||||
tsdbDebugFlag = 0;
|
||||
cqDebugFlag = 0;
|
||||
tscEmbeddedInUtil = 1;
|
||||
tsAsyncLog = 0;
|
||||
|
||||
taosRemoveDir(path);
|
||||
taosMkDir(path);
|
||||
|
||||
char temp[PATH_MAX];
|
||||
snprintf(temp, PATH_MAX, "%s/taosdlog", path);
|
||||
if (taosInitLog(temp, tsNumOfLogLines, 1) != 0) {
|
||||
tstrncpy(tsLogDir, path, PATH_MAX);
|
||||
if (taosInitLog("taosdlog", 1) != 0) {
|
||||
printf("failed to init log file\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Testbase::Init(const char* path, int16_t port) {
|
||||
SDnodeEnvCfg cfg = {0};
|
||||
cfg.numOfCommitThreads = 1;
|
||||
cfg.numOfCores = 1;
|
||||
dndInit(&cfg);
|
||||
dndInit();
|
||||
|
||||
char fqdn[] = "localhost";
|
||||
char firstEp[TSDB_EP_LEN] = {0};
|
||||
|
|
|
@ -123,6 +123,7 @@ typedef enum {
|
|||
TRN_TYPE_DROP_TOPIC = 1015,
|
||||
TRN_TYPE_SUBSCRIBE = 1016,
|
||||
TRN_TYPE_REBALANCE = 1017,
|
||||
TRN_TYPE_COMMIT_OFFSET = 1018,
|
||||
TRN_TYPE_BASIC_SCOPE_END,
|
||||
TRN_TYPE_GLOBAL_SCOPE = 2000,
|
||||
TRN_TYPE_CREATE_DNODE = 2001,
|
||||
|
@ -176,7 +177,7 @@ typedef struct {
|
|||
SArray* undoActions;
|
||||
int64_t createdTime;
|
||||
int64_t lastExecTime;
|
||||
uint64_t dbUid;
|
||||
int64_t dbUid;
|
||||
char dbname[TSDB_DB_FNAME_LEN];
|
||||
char lastError[TSDB_TRANS_ERROR_LEN];
|
||||
} STrans;
|
||||
|
@ -304,16 +305,16 @@ typedef struct {
|
|||
} SDbCfg;
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_DB_FNAME_LEN];
|
||||
char acct[TSDB_USER_LEN];
|
||||
char createUser[TSDB_USER_LEN];
|
||||
int64_t createdTime;
|
||||
int64_t updateTime;
|
||||
uint64_t uid;
|
||||
int32_t cfgVersion;
|
||||
int32_t vgVersion;
|
||||
int8_t hashMethod; // default is 1
|
||||
SDbCfg cfg;
|
||||
char name[TSDB_DB_FNAME_LEN];
|
||||
char acct[TSDB_USER_LEN];
|
||||
char createUser[TSDB_USER_LEN];
|
||||
int64_t createdTime;
|
||||
int64_t updateTime;
|
||||
int64_t uid;
|
||||
int32_t cfgVersion;
|
||||
int32_t vgVersion;
|
||||
int8_t hashMethod; // default is 1
|
||||
SDbCfg cfg;
|
||||
} SDbObj;
|
||||
|
||||
typedef struct {
|
||||
|
@ -346,8 +347,8 @@ typedef struct {
|
|||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t createdTime;
|
||||
int64_t updateTime;
|
||||
uint64_t uid;
|
||||
uint64_t dbUid;
|
||||
int64_t uid;
|
||||
int64_t dbUid;
|
||||
int32_t version;
|
||||
int32_t nextColId;
|
||||
int32_t numOfColumns;
|
||||
|
@ -465,6 +466,24 @@ static FORCE_INLINE void tDeleteSMqSubConsumer(SMqSubConsumer* pSubConsumer) {
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char key[TSDB_PARTITION_KEY_LEN];
|
||||
int64_t offset;
|
||||
} SMqOffsetObj;
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSMqOffsetObj(void** buf, const SMqOffsetObj* pOffset) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeString(buf, pOffset->key);
|
||||
tlen += taosEncodeFixedI64(buf, pOffset->offset);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset) {
|
||||
buf = taosDecodeStringTo(buf, pOffset->key);
|
||||
buf = taosDecodeFixedI64(buf, &pOffset->offset);
|
||||
return buf;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||
int32_t status;
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "tqueue.h"
|
||||
#include "ttime.h"
|
||||
#include "wal.h"
|
||||
#include "version.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -56,12 +58,9 @@ typedef struct {
|
|||
} SProfileMgmt;
|
||||
|
||||
typedef struct {
|
||||
int8_t enable;
|
||||
pthread_mutex_t lock;
|
||||
pthread_cond_t cond;
|
||||
volatile int32_t exit;
|
||||
pthread_t thread;
|
||||
char email[TSDB_FQDN_LEN];
|
||||
bool enable;
|
||||
SRWLatch lock;
|
||||
char email[TSDB_FQDN_LEN];
|
||||
} STelemMgmt;
|
||||
|
||||
typedef struct {
|
||||
|
@ -81,8 +80,8 @@ typedef struct SMnode {
|
|||
tmr_h timer;
|
||||
tmr_h transTimer;
|
||||
tmr_h mqTimer;
|
||||
tmr_h telemTimer;
|
||||
char *path;
|
||||
SMnodeCfg cfg;
|
||||
int64_t checkTime;
|
||||
SSdb *pSdb;
|
||||
SDnode *pDnode;
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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_MND_OFFSET_H_
|
||||
#define _TD_MND_OFFSET_H_
|
||||
|
||||
#include "mndInt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t mndInitOffset(SMnode *pMnode);
|
||||
void mndCleanupOffset(SMnode *pMnode);
|
||||
|
||||
SMqOffsetObj *mndAcquireOffset(SMnode *pMnode, const char *key);
|
||||
void mndReleaseOffset(SMnode *pMnode, SMqOffsetObj *pOffset);
|
||||
|
||||
SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset);
|
||||
SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw);
|
||||
|
||||
int32_t mndCreateOffset(STrans *pTrans, const char *cgroup, const char *topicName, const SArray *vgs);
|
||||
|
||||
static FORCE_INLINE int32_t mndMakePartitionKey(char *key, const char *cgroup, const char *topicName, int32_t vgId) {
|
||||
return snprintf(key, TSDB_PARTITION_KEY_LEN, "%d:%s:%s", vgId, cgroup, topicName);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_MND_OFFSET_H_*/
|
|
@ -52,7 +52,7 @@ int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len) {
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
SClusterObj *pCluster = sdbAcquire(pSdb, SDB_CLUSTER, &pMnode->clusterId);
|
||||
if (pCluster = NULL) {
|
||||
if (pCluster == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#include "mndUser.h"
|
||||
#include "mndVgroup.h"
|
||||
|
||||
#define TSDB_DNODE_VER_NUMBER 1
|
||||
#define TSDB_DNODE_VER_NUMBER 1
|
||||
#define TSDB_DNODE_RESERVE_SIZE 64
|
||||
#define TSDB_CONFIG_OPTION_LEN 16
|
||||
#define TSDB_CONIIG_VALUE_LEN 48
|
||||
#define TSDB_CONFIG_NUMBER 8
|
||||
#define TSDB_CONFIG_OPTION_LEN 16
|
||||
#define TSDB_CONIIG_VALUE_LEN 48
|
||||
#define TSDB_CONFIG_NUMBER 8
|
||||
|
||||
static const char *offlineReason[] = {
|
||||
"",
|
||||
|
@ -237,7 +237,7 @@ int32_t mndGetDnodeSize(SMnode *pMnode) {
|
|||
|
||||
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
|
||||
int64_t interval = TABS(pDnode->lastAccessTime - curMs);
|
||||
if (interval > 3500 * pMnode->cfg.statusInterval) {
|
||||
if (interval > 3500 * tsStatusInterval) {
|
||||
if (pDnode->rebootTime > 0) {
|
||||
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
||||
}
|
||||
|
@ -272,24 +272,24 @@ static void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeEps) {
|
|||
}
|
||||
|
||||
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
|
||||
if (pCfg->statusInterval != pMnode->cfg.statusInterval) {
|
||||
mError("statusInterval [%d - %d] cfg inconsistent", pCfg->statusInterval, pMnode->cfg.statusInterval);
|
||||
if (pCfg->statusInterval != tsStatusInterval) {
|
||||
mError("statusInterval [%d - %d] cfg inconsistent", pCfg->statusInterval, tsStatusInterval);
|
||||
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
|
||||
}
|
||||
|
||||
if ((0 != strcasecmp(pCfg->timezone, pMnode->cfg.timezone)) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, pMnode->cfg.timezone,
|
||||
if ((0 != strcasecmp(pCfg->timezone, tsTimezone)) && (pMnode->checkTime != pCfg->checkTime)) {
|
||||
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, tsTimezone,
|
||||
pCfg->checkTime, pMnode->checkTime);
|
||||
return DND_REASON_TIME_ZONE_NOT_MATCH;
|
||||
}
|
||||
|
||||
if (0 != strcasecmp(pCfg->locale, pMnode->cfg.locale)) {
|
||||
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, pMnode->cfg.locale);
|
||||
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
|
||||
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, tsLocale);
|
||||
return DND_REASON_LOCALE_NOT_MATCH;
|
||||
}
|
||||
|
||||
if (0 != strcasecmp(pCfg->charset, pMnode->cfg.charset)) {
|
||||
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, pMnode->cfg.charset);
|
||||
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
|
||||
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, tsCharset);
|
||||
return DND_REASON_CHARSET_NOT_MATCH;
|
||||
}
|
||||
|
||||
|
@ -355,12 +355,11 @@ static int32_t mndProcessStatusReq(SMnodeMsg *pReq) {
|
|||
bool needCheck = !online || dnodeChanged || reboot;
|
||||
|
||||
if (needCheck) {
|
||||
if (statusReq.sver != pMnode->cfg.sver) {
|
||||
if (statusReq.sver != tsVersion) {
|
||||
if (pDnode != NULL) {
|
||||
pDnode->offlineReason = DND_REASON_VERSION_NOT_MATCH;
|
||||
}
|
||||
mError("dnode:%d, status msg version:%d not match cluster:%d", statusReq.dnodeId, statusReq.sver,
|
||||
pMnode->cfg.sver);
|
||||
mError("dnode:%d, status msg version:%d not match cluster:%d", statusReq.dnodeId, statusReq.sver, tsVersion);
|
||||
terrno = TSDB_CODE_MND_INVALID_MSG_VERSION;
|
||||
goto PROCESS_STATUS_MSG_OVER;
|
||||
}
|
||||
|
@ -632,13 +631,13 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
|
|||
|
||||
pShow->bytes[cols] = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(pSchema[cols].name, "name", sizeof(pSchema[cols].name));
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_CONIIG_VALUE_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(pSchema[cols].name, "value", sizeof(pSchema[cols].name));
|
||||
strcpy(pSchema[cols].name, "value");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
|
@ -659,29 +658,30 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
|
|||
|
||||
static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
int32_t totalRows = 0;
|
||||
int32_t numOfRows = 0;
|
||||
char *cfgOpts[TSDB_CONFIG_NUMBER] = {0};
|
||||
char cfgVals[TSDB_CONFIG_NUMBER][TSDB_CONIIG_VALUE_LEN + 1] = {0};
|
||||
char *pWrite;
|
||||
int32_t cols = 0;
|
||||
|
||||
cfgOpts[numOfRows] = "statusInterval";
|
||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%d", pMnode->cfg.statusInterval);
|
||||
numOfRows++;
|
||||
cfgOpts[totalRows] = "statusInterval";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONIIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[numOfRows] = "timezone";
|
||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.timezone);
|
||||
numOfRows++;
|
||||
cfgOpts[totalRows] = "timezone";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONIIG_VALUE_LEN, "%s", tsTimezone);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[numOfRows] = "locale";
|
||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.locale);
|
||||
numOfRows++;
|
||||
cfgOpts[totalRows] = "locale";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONIIG_VALUE_LEN, "%s", tsLocale);
|
||||
totalRows++;
|
||||
|
||||
cfgOpts[numOfRows] = "charset";
|
||||
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", pMnode->cfg.charset);
|
||||
numOfRows++;
|
||||
cfgOpts[totalRows] = "charset";
|
||||
snprintf(cfgVals[totalRows], TSDB_CONIIG_VALUE_LEN, "%s", tsCharset);
|
||||
totalRows++;
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; i++) {
|
||||
for (int32_t i = 0; i < totalRows; i++) {
|
||||
cols = 0;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
@ -691,6 +691,8 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data,
|
|||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, cfgVals[i], TSDB_CONIIG_VALUE_LEN);
|
||||
cols++;
|
||||
|
||||
numOfRows++;
|
||||
}
|
||||
|
||||
mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow);
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
* 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 "mndOffset.h"
|
||||
#include "mndAuth.h"
|
||||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndStb.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
#include "mndVgroup.h"
|
||||
#include "tname.h"
|
||||
|
||||
#define MND_OFFSET_VER_NUMBER 1
|
||||
#define MND_OFFSET_RESERVE_SIZE 64
|
||||
|
||||
static int32_t mndOffsetActionInsert(SSdb *pSdb, SMqOffsetObj *pOffset);
|
||||
static int32_t mndOffsetActionDelete(SSdb *pSdb, SMqOffsetObj *pOffset);
|
||||
static int32_t mndOffsetActionUpdate(SSdb *pSdb, SMqOffsetObj *pOffset, SMqOffsetObj *pNewOffset);
|
||||
static int32_t mndProcessCommitOffsetReq(SMnodeMsg *pReq);
|
||||
|
||||
int32_t mndInitOffset(SMnode *pMnode) {
|
||||
SSdbTable table = {.sdbType = SDB_OFFSET,
|
||||
.keyType = SDB_KEY_BINARY,
|
||||
.encodeFp = (SdbEncodeFp)mndOffsetActionEncode,
|
||||
.decodeFp = (SdbDecodeFp)mndOffsetActionDecode,
|
||||
.insertFp = (SdbInsertFp)mndOffsetActionInsert,
|
||||
.updateFp = (SdbUpdateFp)mndOffsetActionUpdate,
|
||||
.deleteFp = (SdbDeleteFp)mndOffsetActionDelete};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_COMMIT_OFFSET, mndProcessCommitOffsetReq);
|
||||
|
||||
return sdbSetTable(pMnode->pSdb, table);
|
||||
}
|
||||
|
||||
void mndCleanupOffset(SMnode *pMnode) {}
|
||||
|
||||
SSdbRaw *mndOffsetActionEncode(SMqOffsetObj *pOffset) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
void *buf = NULL;
|
||||
int32_t tlen = tEncodeSMqOffsetObj(NULL, pOffset);
|
||||
int32_t size = sizeof(int32_t) + tlen + MND_OFFSET_RESERVE_SIZE;
|
||||
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_OFFSET, MND_OFFSET_VER_NUMBER, size);
|
||||
if (pRaw == NULL) goto OFFSET_ENCODE_OVER;
|
||||
|
||||
buf = malloc(tlen);
|
||||
if (buf == NULL) goto OFFSET_ENCODE_OVER;
|
||||
|
||||
void *abuf = buf;
|
||||
tEncodeSMqOffsetObj(&abuf, pOffset);
|
||||
|
||||
int32_t dataPos = 0;
|
||||
SDB_SET_INT32(pRaw, dataPos, tlen, OFFSET_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, buf, tlen, OFFSET_ENCODE_OVER);
|
||||
SDB_SET_RESERVE(pRaw, dataPos, MND_OFFSET_RESERVE_SIZE, OFFSET_ENCODE_OVER);
|
||||
SDB_SET_DATALEN(pRaw, dataPos, OFFSET_ENCODE_OVER);
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
OFFSET_ENCODE_OVER:
|
||||
tfree(buf);
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
mError("offset:%s, failed to encode to raw:%p since %s", pOffset->key, pRaw, terrstr());
|
||||
sdbFreeRaw(pRaw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mTrace("offset:%s, encode to raw:%p, row:%p", pOffset->key, pRaw, pOffset);
|
||||
return pRaw;
|
||||
}
|
||||
|
||||
SSdbRow *mndOffsetActionDecode(SSdbRaw *pRaw) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
void *buf = NULL;
|
||||
|
||||
int8_t sver = 0;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto OFFSET_DECODE_OVER;
|
||||
|
||||
if (sver != MND_OFFSET_VER_NUMBER) {
|
||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||
goto OFFSET_DECODE_OVER;
|
||||
}
|
||||
|
||||
int32_t size = sizeof(SMqOffsetObj);
|
||||
SSdbRow *pRow = sdbAllocRow(size);
|
||||
if (pRow == NULL) goto OFFSET_DECODE_OVER;
|
||||
|
||||
SMqOffsetObj *pOffset = sdbGetRowObj(pRow);
|
||||
if (pOffset == NULL) goto OFFSET_DECODE_OVER;
|
||||
|
||||
int32_t dataPos = 0;
|
||||
int32_t tlen;
|
||||
SDB_GET_INT32(pRaw, dataPos, &tlen, OFFSET_DECODE_OVER);
|
||||
buf = malloc(tlen + 1);
|
||||
if (buf == NULL) goto OFFSET_DECODE_OVER;
|
||||
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, OFFSET_DECODE_OVER);
|
||||
SDB_GET_RESERVE(pRaw, dataPos, MND_OFFSET_RESERVE_SIZE, OFFSET_DECODE_OVER);
|
||||
|
||||
if (tDecodeSMqOffsetObj(buf, pOffset) == NULL) {
|
||||
goto OFFSET_DECODE_OVER;
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
OFFSET_DECODE_OVER:
|
||||
tfree(buf);
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
mError("offset:%s, failed to decode from raw:%p since %s", pOffset->key, pRaw, terrstr());
|
||||
tfree(pRow);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mTrace("offset:%s, decode from raw:%p, row:%p", pOffset->key, pRaw, pOffset);
|
||||
return pRow;
|
||||
}
|
||||
|
||||
int32_t mndCreateOffset(STrans *pTrans, const char *cgroup, const char *topicName, const SArray *vgs) {
|
||||
int32_t code = 0;
|
||||
int32_t sz = taosArrayGetSize(vgs);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqConsumerEp *pConsumerEp = taosArrayGet(vgs, i);
|
||||
SMqOffsetObj offsetObj;
|
||||
if (mndMakePartitionKey(offsetObj.key, cgroup, topicName, pConsumerEp->vgId) < 0) {
|
||||
return -1;
|
||||
}
|
||||
offsetObj.offset = -1;
|
||||
SSdbRaw *pOffsetRaw = mndOffsetActionEncode(&offsetObj);
|
||||
if (pOffsetRaw == NULL) {
|
||||
return -1;
|
||||
}
|
||||
sdbSetRawStatus(pOffsetRaw, SDB_STATUS_READY);
|
||||
if (mndTransAppendRedolog(pTrans, pOffsetRaw) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCommitOffsetReq(SMnodeMsg *pMsg) {
|
||||
char key[TSDB_PARTITION_KEY_LEN];
|
||||
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
char *msgStr = pMsg->rpcMsg.pCont;
|
||||
SMqCMCommitOffsetReq commitOffsetReq;
|
||||
SCoder decoder;
|
||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, msgStr, pMsg->rpcMsg.contLen, TD_DECODER);
|
||||
|
||||
tDecodeSMqCMCommitOffsetReq(&decoder, &commitOffsetReq);
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_COMMIT_OFFSET, &pMsg->rpcMsg);
|
||||
|
||||
for (int32_t i = 0; i < commitOffsetReq.num; i++) {
|
||||
SMqOffset *pOffset = &commitOffsetReq.offsets[i];
|
||||
if (mndMakePartitionKey(key, pOffset->cgroup, pOffset->topicName, pOffset->vgId) < 0) {
|
||||
return -1;
|
||||
}
|
||||
SMqOffsetObj *pOffsetObj = mndAcquireOffset(pMnode, key);
|
||||
ASSERT(pOffsetObj);
|
||||
pOffsetObj->offset = pOffset->offset;
|
||||
SSdbRaw *pOffsetRaw = mndOffsetActionEncode(pOffsetObj);
|
||||
sdbSetRawStatus(pOffsetRaw, SDB_STATUS_READY);
|
||||
mndTransAppendRedolog(pTrans, pOffsetRaw);
|
||||
mndReleaseOffset(pMnode, pOffsetObj);
|
||||
}
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("mq-commit-offset-trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mndTransDrop(pTrans);
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
static int32_t mndOffsetActionInsert(SSdb *pSdb, SMqOffsetObj *pOffset) {
|
||||
mTrace("offset:%s, perform insert action", pOffset->key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndOffsetActionDelete(SSdb *pSdb, SMqOffsetObj *pOffset) {
|
||||
mTrace("offset:%s, perform delete action", pOffset->key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndOffsetActionUpdate(SSdb *pSdb, SMqOffsetObj *pOldOffset, SMqOffsetObj *pNewOffset) {
|
||||
mTrace("offset:%s, perform update action", pOldOffset->key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SMqOffsetObj *mndAcquireOffset(SMnode *pMnode, const char *key) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SMqOffsetObj *pOffset = sdbAcquire(pSdb, SDB_OFFSET, key);
|
||||
if (pOffset == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) {
|
||||
terrno = TSDB_CODE_MND_OFFSET_NOT_EXIST;
|
||||
}
|
||||
return pOffset;
|
||||
}
|
||||
|
||||
void mndReleaseOffset(SMnode *pMnode, SMqOffsetObj *pOffset) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
sdbRelease(pSdb, pOffset);
|
||||
}
|
||||
|
||||
static void mndCancelGetNextOffset(SMnode *pMnode, void *pIter) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
}
|
|
@ -21,6 +21,7 @@
|
|||
#include "mndStb.h"
|
||||
#include "mndUser.h"
|
||||
#include "tglobal.h"
|
||||
#include "version.h"
|
||||
|
||||
#define QUERY_ID_SIZE 20
|
||||
#define QUERY_OBJ_ID_SIZE 18
|
||||
|
@ -62,7 +63,7 @@ static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter);
|
|||
int32_t mndInitProfile(SMnode *pMnode) {
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
int32_t connCheckTime = pMnode->cfg.shellActivityTimer * 2;
|
||||
int32_t connCheckTime = tsShellActivityTimer * 2;
|
||||
pMgmt->cache = taosCacheInit(TSDB_DATA_TYPE_INT, connCheckTime, true, (__cache_free_fn_t)mndFreeConn, "conn");
|
||||
if (pMgmt->cache == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -116,7 +117,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
|
|||
tstrncpy(connObj.user, pInfo->user, TSDB_USER_LEN);
|
||||
tstrncpy(connObj.app, app, TSDB_APP_NAME_LEN);
|
||||
|
||||
int32_t keepTime = pMnode->cfg.shellActivityTimer * 3;
|
||||
int32_t keepTime = tsShellActivityTimer * 3;
|
||||
SConnObj *pConn = taosCachePut(pMgmt->cache, &connId, sizeof(int32_t), &connObj, sizeof(connObj), keepTime * 1000);
|
||||
if (pConn == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -142,7 +143,7 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int32_t keepTime = pMnode->cfg.shellActivityTimer * 3;
|
||||
int32_t keepTime = tsShellActivityTimer * 3;
|
||||
pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs();
|
||||
|
||||
mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn);
|
||||
|
|
|
@ -64,7 +64,7 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq) {
|
|||
memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN);
|
||||
memcpy(showObj.payload, pReq->payload, pReq->payloadLen);
|
||||
|
||||
int32_t keepTime = pMnode->cfg.shellActivityTimer * 6 * 1000;
|
||||
int32_t keepTime = tsShellActivityTimer * 6 * 1000;
|
||||
SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime);
|
||||
if (pShow == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndOffset.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndStb.h"
|
||||
#include "mndTopic.h"
|
||||
|
@ -80,13 +81,13 @@ int32_t mndInitSubscribe(SMnode *pMnode) {
|
|||
return sdbSetTable(pMnode->pSdb, table);
|
||||
}
|
||||
|
||||
static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj *pTopic, const char *consumerGroup) {
|
||||
static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj *pTopic, const char *cgroup) {
|
||||
SMqSubscribeObj *pSub = tNewSubscribeObj();
|
||||
if (pSub == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
char *key = mndMakeSubscribeKey(consumerGroup, pTopic->name);
|
||||
char *key = mndMakeSubscribeKey(cgroup, pTopic->name);
|
||||
if (key == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tDeleteSMqSubscribeObj(pSub);
|
||||
|
@ -289,9 +290,15 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
|
|||
strcpy(topicEp.topic, topicName);
|
||||
topicEp.vgs = taosArrayInit(vgsz, sizeof(SMqSubVgEp));
|
||||
for (int32_t k = 0; k < vgsz; k++) {
|
||||
char offsetKey[TSDB_PARTITION_KEY_LEN];
|
||||
SMqConsumerEp *pConsumerEp = taosArrayGet(pSubConsumer->vgInfo, k);
|
||||
|
||||
SMqSubVgEp vgEp = {.epSet = pConsumerEp->epSet, .vgId = pConsumerEp->vgId};
|
||||
SMqSubVgEp vgEp = {.epSet = pConsumerEp->epSet, .vgId = pConsumerEp->vgId, .offset = -1};
|
||||
mndMakePartitionKey(offsetKey, pConsumer->cgroup, topicName, pConsumerEp->vgId);
|
||||
SMqOffsetObj *pOffsetObj = mndAcquireOffset(pMnode, offsetKey);
|
||||
if (pOffsetObj != NULL) {
|
||||
vgEp.offset = pOffsetObj->offset;
|
||||
mndReleaseOffset(pMnode, pOffsetObj);
|
||||
}
|
||||
taosArrayPush(topicEp.vgs, &vgEp);
|
||||
}
|
||||
taosArrayPush(rsp.topics, &topicEp);
|
||||
|
@ -870,7 +877,7 @@ static SSdbRaw *mndSubActionEncode(SMqSubscribeObj *pSub) {
|
|||
|
||||
SUB_ENCODE_OVER:
|
||||
tfree(buf);
|
||||
if (terrno != 0) {
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
mError("subscribe:%s, failed to encode to raw:%p since %s", pSub->key, pRaw, terrstr());
|
||||
sdbFreeRaw(pRaw);
|
||||
return NULL;
|
||||
|
@ -1085,6 +1092,8 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
|
|||
mDebug("create new subscription by consumer %ld, group: %s, topic %s", consumerId, cgroup, newTopicName);
|
||||
pSub = mndCreateSubscription(pMnode, pTopic, cgroup);
|
||||
createSub = true;
|
||||
|
||||
mndCreateOffset(pTrans, cgroup, newTopicName, pSub->unassignedVg);
|
||||
}
|
||||
|
||||
SMqSubConsumer mqSubConsumer;
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "tversion.h"
|
||||
|
||||
#define TELEMETRY_SERVER "telemetry.taosdata.com"
|
||||
#define TELEMETRY_PORT 80
|
||||
#define REPORT_INTERVAL 86400
|
||||
#define TELEMETRY_PORT 80
|
||||
#define REPORT_INTERVAL 86400
|
||||
|
||||
static void mndBeginObject(SBufferWriter* bw) { tbufWriteChar(bw, '{'); }
|
||||
|
||||
|
@ -33,25 +33,8 @@ static void mndCloseObject(SBufferWriter* bw) {
|
|||
} else {
|
||||
tbufWriteChar(bw, '}');
|
||||
}
|
||||
tbufWriteChar(bw, ',');
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void beginArray(SBufferWriter* bw) {
|
||||
tbufWriteChar(bw, '[');
|
||||
}
|
||||
|
||||
static void closeArray(SBufferWriter* bw) {
|
||||
size_t len = tbufTell(bw);
|
||||
if (tbufGetData(bw, false)[len - 1] == ',') {
|
||||
tbufWriteCharAt(bw, len - 1, ']');
|
||||
} else {
|
||||
tbufWriteChar(bw, ']');
|
||||
}
|
||||
tbufWriteChar(bw, ',');
|
||||
}
|
||||
#endif
|
||||
|
||||
static void mndWriteString(SBufferWriter* bw, const char* str) {
|
||||
tbufWriteChar(bw, '"');
|
||||
tbufWrite(bw, str, strlen(str));
|
||||
|
@ -61,7 +44,7 @@ static void mndWriteString(SBufferWriter* bw, const char* str) {
|
|||
static void mndAddIntField(SBufferWriter* bw, const char* k, int64_t v) {
|
||||
mndWriteString(bw, k);
|
||||
tbufWriteChar(bw, ':');
|
||||
char buf[32];
|
||||
char buf[32] = {0};
|
||||
sprintf(buf, "%" PRId64, v);
|
||||
tbufWrite(bw, buf, strlen(buf));
|
||||
tbufWriteChar(bw, ',');
|
||||
|
@ -79,12 +62,13 @@ static void mndAddCpuInfo(SMnode* pMnode, SBufferWriter* bw) {
|
|||
size_t size = 0;
|
||||
int32_t done = 0;
|
||||
|
||||
FILE* fp = fopen("/proc/cpuinfo", "r");
|
||||
if (fp == NULL) {
|
||||
// FILE* fp = fopen("/proc/cpuinfo", "r");
|
||||
TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (done != 3 && (size = tgetline(&line, &size, fp)) != -1) {
|
||||
while (done != 3 && (size = taosGetLineFile(pFile, &line)) != -1) {
|
||||
line[size - 1] = '\0';
|
||||
if (((done & 1) == 0) && strncmp(line, "model name", 10) == 0) {
|
||||
const char* v = strchr(line, ':') + 2;
|
||||
|
@ -100,20 +84,21 @@ static void mndAddCpuInfo(SMnode* pMnode, SBufferWriter* bw) {
|
|||
}
|
||||
}
|
||||
|
||||
free(line);
|
||||
fclose(fp);
|
||||
if(line != NULL) free(line);
|
||||
taosCloseFile(&pFile);
|
||||
}
|
||||
|
||||
static void mndAddOsInfo(SMnode* pMnode, SBufferWriter* bw) {
|
||||
char* line = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
FILE* fp = fopen("/etc/os-release", "r");
|
||||
if (fp == NULL) {
|
||||
// FILE* fp = fopen("/etc/os-release", "r");
|
||||
TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ((size = tgetline(&line, &size, fp)) != -1) {
|
||||
while ((size = taosGetLineFile(pFile, &line)) != -1) {
|
||||
line[size - 1] = '\0';
|
||||
if (strncmp(line, "PRETTY_NAME", 11) == 0) {
|
||||
const char* p = strchr(line, '=') + 1;
|
||||
|
@ -126,20 +111,21 @@ static void mndAddOsInfo(SMnode* pMnode, SBufferWriter* bw) {
|
|||
}
|
||||
}
|
||||
|
||||
free(line);
|
||||
fclose(fp);
|
||||
if(line != NULL) free(line);
|
||||
taosCloseFile(&pFile);
|
||||
}
|
||||
|
||||
static void mndAddMemoryInfo(SMnode* pMnode, SBufferWriter* bw) {
|
||||
char* line = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
FILE* fp = fopen("/proc/meminfo", "r");
|
||||
if (fp == NULL) {
|
||||
// FILE* fp = fopen("/proc/meminfo", "r");
|
||||
TdFilePtr pFile = taosOpenFile("/proc/meminfo", TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ((size = tgetline(&line, &size, fp)) != -1) {
|
||||
while ((size = taosGetLineFile(pFile, &line)) != -1) {
|
||||
line[size - 1] = '\0';
|
||||
if (strncmp(line, "MemTotal", 8) == 0) {
|
||||
const char* p = strchr(line, ':') + 1;
|
||||
|
@ -149,19 +135,15 @@ static void mndAddMemoryInfo(SMnode* pMnode, SBufferWriter* bw) {
|
|||
}
|
||||
}
|
||||
|
||||
free(line);
|
||||
fclose(fp);
|
||||
if(line != NULL) free(line);
|
||||
taosCloseFile(&pFile);
|
||||
}
|
||||
|
||||
static void mndAddVersionInfo(SMnode* pMnode, SBufferWriter* bw) {
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
|
||||
char vstr[32] = {0};
|
||||
taosVersionIntToStr(pMnode->cfg.sver, vstr, 32);
|
||||
|
||||
mndAddStringField(bw, "version", vstr);
|
||||
mndAddStringField(bw, "buildInfo", pMnode->cfg.buildinfo);
|
||||
mndAddStringField(bw, "gitInfo", pMnode->cfg.gitinfo);
|
||||
mndAddStringField(bw, "version", version);
|
||||
mndAddStringField(bw, "buildInfo", buildinfo);
|
||||
mndAddStringField(bw, "gitInfo", gitinfo);
|
||||
mndAddStringField(bw, "email", pMgmt->email);
|
||||
}
|
||||
|
||||
|
@ -184,24 +166,17 @@ static void mndAddRuntimeInfo(SMnode* pMnode, SBufferWriter* bw) {
|
|||
}
|
||||
|
||||
static void mndSendTelemetryReport(SMnode* pMnode) {
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
|
||||
char buf[128] = {0};
|
||||
uint32_t ip = taosGetIpv4FromFqdn(TELEMETRY_SERVER);
|
||||
if (ip == 0xffffffff) {
|
||||
mDebug("failed to get IP address of " TELEMETRY_SERVER " since :%s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
SOCKET fd = taosOpenTcpClientSocket(ip, TELEMETRY_PORT, 0);
|
||||
if (fd < 0) {
|
||||
mDebug("failed to create socket for telemetry, reason:%s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
SBufferWriter bw = tbufInitWriter(NULL, false);
|
||||
int32_t code = -1;
|
||||
char buf[128] = {0};
|
||||
SOCKET fd = 0;
|
||||
|
||||
char clusterName[64] = {0};
|
||||
mndGetClusterName(pMnode, clusterName, sizeof(clusterName));
|
||||
if (mndGetClusterName(pMnode, clusterName, sizeof(clusterName)) != 0) {
|
||||
goto SEND_OVER;
|
||||
}
|
||||
|
||||
SBufferWriter bw = tbufInitWriter(NULL, false);
|
||||
mndBeginObject(&bw);
|
||||
mndAddStringField(&bw, "instanceId", clusterName);
|
||||
mndAddIntField(&bw, "reportVersion", 1);
|
||||
|
@ -212,111 +187,95 @@ static void mndSendTelemetryReport(SMnode* pMnode) {
|
|||
mndAddRuntimeInfo(pMnode, &bw);
|
||||
mndCloseObject(&bw);
|
||||
|
||||
uint32_t ip = taosGetIpv4FromFqdn(TELEMETRY_SERVER);
|
||||
if (ip == 0xffffffff) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to get ip of %s since :%s", TELEMETRY_SERVER, terrstr());
|
||||
goto SEND_OVER;
|
||||
}
|
||||
|
||||
fd = taosOpenTcpClientSocket(ip, TELEMETRY_PORT, 0);
|
||||
if (fd < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to create socket to %s:%d since:%s", TELEMETRY_SERVER, TELEMETRY_PORT, terrstr());
|
||||
goto SEND_OVER;
|
||||
}
|
||||
|
||||
const char* header =
|
||||
"POST /report HTTP/1.1\n"
|
||||
"Host: " TELEMETRY_SERVER
|
||||
"\n"
|
||||
"Content-Type: application/json\n"
|
||||
"Content-Length: ";
|
||||
if (taosWriteSocket(fd, (void*)header, (int32_t)strlen(header)) < 0) {
|
||||
goto SEND_OVER;
|
||||
}
|
||||
|
||||
taosWriteSocket(fd, (void*)header, (int32_t)strlen(header));
|
||||
int32_t contLen = (int32_t)(tbufTell(&bw) - 1);
|
||||
int32_t contLen = (int32_t)(tbufTell(&bw));
|
||||
sprintf(buf, "%d\n\n", contLen);
|
||||
taosWriteSocket(fd, buf, (int32_t)strlen(buf));
|
||||
taosWriteSocket(fd, tbufGetData(&bw, false), contLen);
|
||||
tbufCloseWriter(&bw);
|
||||
if (taosWriteSocket(fd, buf, (int32_t)strlen(buf)) < 0) {
|
||||
goto SEND_OVER;
|
||||
}
|
||||
|
||||
const char* pCont = tbufGetData(&bw, false);
|
||||
if (taosWriteSocket(fd, (void*)pCont, contLen) < 0) {
|
||||
goto SEND_OVER;
|
||||
}
|
||||
|
||||
// read something to avoid nginx error 499
|
||||
if (taosReadSocket(fd, buf, 10) < 0) {
|
||||
mDebug("failed to receive response since %s", strerror(errno));
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to receive response since %s", terrstr());
|
||||
goto SEND_OVER;
|
||||
}
|
||||
|
||||
mInfo("send telemetry to %s:%d, len:%d content: %s", TELEMETRY_SERVER, TELEMETRY_PORT, contLen, pCont);
|
||||
code = 0;
|
||||
|
||||
SEND_OVER:
|
||||
tbufCloseWriter(&bw);
|
||||
taosCloseSocket(fd);
|
||||
|
||||
if (code != 0) {
|
||||
mError("failed to send telemetry to %s:%d since %s", TELEMETRY_SERVER, TELEMETRY_PORT, terrstr());
|
||||
}
|
||||
}
|
||||
|
||||
static void* mndTelemThreadFp(void* param) {
|
||||
SMnode* pMnode = param;
|
||||
static int32_t mndProcessTelemTimer(SMnodeMsg* pReq) {
|
||||
SMnode* pMnode = pReq->pMnode;
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
if (!pMgmt->enable) return 0;
|
||||
|
||||
struct timespec end = {0};
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
end.tv_sec += 300; // wait 5 minutes before send first report
|
||||
|
||||
setThreadName("mnd-telem");
|
||||
|
||||
while (!pMgmt->exit) {
|
||||
int32_t r = 0;
|
||||
struct timespec ts = end;
|
||||
pthread_mutex_lock(&pMgmt->lock);
|
||||
r = pthread_cond_timedwait(&pMgmt->cond, &pMgmt->lock, &ts);
|
||||
pthread_mutex_unlock(&pMgmt->lock);
|
||||
if (r == 0) break;
|
||||
if (r != ETIMEDOUT) continue;
|
||||
|
||||
if (mndIsMaster(pMnode)) {
|
||||
mndSendTelemetryReport(pMnode);
|
||||
}
|
||||
end.tv_sec += REPORT_INTERVAL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
taosWLockLatch(&pMgmt->lock);
|
||||
mndSendTelemetryReport(pMnode);
|
||||
taosWUnLockLatch(&pMgmt->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mndGetEmail(SMnode* pMnode, char* filepath) {
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
|
||||
int32_t fd = taosOpenFileRead(filepath);
|
||||
if (fd < 0) {
|
||||
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (taosReadFile(fd, (void*)pMgmt->email, TSDB_FQDN_LEN) < 0) {
|
||||
if (taosReadFile(pFile, (void*)pMgmt->email, TSDB_FQDN_LEN) < 0) {
|
||||
mError("failed to read %d bytes from file %s since %s", TSDB_FQDN_LEN, filepath, strerror(errno));
|
||||
}
|
||||
|
||||
taosCloseFile(fd);
|
||||
taosCloseFile(&pFile);
|
||||
}
|
||||
|
||||
int32_t mndInitTelem(SMnode* pMnode) {
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
pMgmt->enable = pMnode->cfg.enableTelem;
|
||||
|
||||
if (!pMgmt->enable) return 0;
|
||||
|
||||
pMgmt->exit = 0;
|
||||
pthread_mutex_init(&pMgmt->lock, NULL);
|
||||
pthread_cond_init(&pMgmt->cond, NULL);
|
||||
pMgmt->email[0] = 0;
|
||||
|
||||
pMgmt->enable = tsEnableTelemetryReporting;
|
||||
taosInitRWLatch(&pMgmt->lock);
|
||||
mndGetEmail(pMnode, "/usr/local/taos/email");
|
||||
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
int32_t code = pthread_create(&pMgmt->thread, &attr, mndTelemThreadFp, pMnode);
|
||||
pthread_attr_destroy(&attr);
|
||||
if (code != 0) {
|
||||
mDebug("failed to create telemetry thread since :%s", strerror(code));
|
||||
}
|
||||
|
||||
mInfo("mnd telemetry is initialized");
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer);
|
||||
mDebug("mnode telemetry is initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndCleanupTelem(SMnode* pMnode) {
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
if (!pMgmt->enable) return;
|
||||
|
||||
if (taosCheckPthreadValid(pMgmt->thread)) {
|
||||
pthread_mutex_lock(&pMgmt->lock);
|
||||
pMgmt->exit = 1;
|
||||
pthread_cond_signal(&pMgmt->cond);
|
||||
pthread_mutex_unlock(&pMgmt->lock);
|
||||
|
||||
pthread_join(pMgmt->thread, NULL);
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(&pMgmt->lock);
|
||||
pthread_cond_destroy(&pMgmt->cond);
|
||||
}
|
||||
void mndCleanupTelem(SMnode* pMnode) {}
|
||||
|
|
|
@ -71,7 +71,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
|
|||
.updateFp = (SdbUpdateFp)mndTransActionUpdate,
|
||||
.deleteFp = (SdbDeleteFp)mndTransActionDelete};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TRANS, mndProcessTransReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq);
|
||||
|
||||
mndAddShowMetaHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndGetTransMeta);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "mndDnode.h"
|
||||
#include "mndFunc.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndOffset.h"
|
||||
#include "mndProfile.h"
|
||||
#include "mndQnode.h"
|
||||
#include "mndShow.h"
|
||||
|
@ -36,6 +37,10 @@
|
|||
#include "mndUser.h"
|
||||
#include "mndVgroup.h"
|
||||
|
||||
#define MQ_TIMER_MS 3000
|
||||
#define TRNAS_TIMER_MS 6000
|
||||
#define TELEM_TIMER_MS 86400000
|
||||
|
||||
int32_t mndSendReqToDnode(SMnode *pMnode, SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||
if (pMnode == NULL || pMnode->sendReqToDnodeFp == NULL) {
|
||||
terrno = TSDB_CODE_MND_NOT_READY;
|
||||
|
@ -73,46 +78,60 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
|
|||
return pReq;
|
||||
}
|
||||
|
||||
static void mndTransReExecute(void *param, void *tmrId) {
|
||||
static void mndPullupTrans(void *param, void *tmrId) {
|
||||
SMnode *pMnode = param;
|
||||
if (mndIsMaster(pMnode)) {
|
||||
int32_t contLen = 0;
|
||||
void * pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS, .pCont = pReq, .contLen = contLen};
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
pMnode->putReqToMWriteQFp(pMnode->pDnode, &rpcMsg);
|
||||
}
|
||||
|
||||
taosTmrReset(mndTransReExecute, 3000, pMnode, pMnode->timer, &pMnode->transTimer);
|
||||
taosTmrReset(mndPullupTrans, TRNAS_TIMER_MS, pMnode, pMnode->timer, &pMnode->transTimer);
|
||||
}
|
||||
|
||||
static void mndCalMqRebalance(void *param, void *tmrId) {
|
||||
SMnode *pMnode = param;
|
||||
if (mndIsMaster(pMnode)) {
|
||||
int32_t contLen = 0;
|
||||
void * pReq = mndBuildTimerMsg(&contLen);
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_MQ_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
pMnode->putReqToMReadQFp(pMnode->pDnode, &rpcMsg);
|
||||
}
|
||||
|
||||
taosTmrReset(mndCalMqRebalance, 3000, pMnode, pMnode->timer, &pMnode->mqTimer);
|
||||
taosTmrReset(mndCalMqRebalance, MQ_TIMER_MS, pMnode, pMnode->timer, &pMnode->mqTimer);
|
||||
}
|
||||
|
||||
static void mndPullupTelem(void *param, void *tmrId) {
|
||||
SMnode *pMnode = param;
|
||||
if (mndIsMaster(pMnode)) {
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
pMnode->putReqToMReadQFp(pMnode->pDnode, &rpcMsg);
|
||||
}
|
||||
|
||||
taosTmrReset(mndPullupTelem, TELEM_TIMER_MS, pMnode, pMnode->timer, &pMnode->telemTimer);
|
||||
}
|
||||
|
||||
static int32_t mndInitTimer(SMnode *pMnode) {
|
||||
if (pMnode->timer == NULL) {
|
||||
pMnode->timer = taosTmrInit(5000, 200, 3600000, "MND");
|
||||
}
|
||||
|
||||
pMnode->timer = taosTmrInit(5000, 200, 3600000, "MND");
|
||||
if (pMnode->timer == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosTmrReset(mndTransReExecute, 6000, pMnode, pMnode->timer, &pMnode->transTimer)) {
|
||||
if (taosTmrReset(mndPullupTrans, TRNAS_TIMER_MS, pMnode, pMnode->timer, &pMnode->transTimer)) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosTmrReset(mndCalMqRebalance, 3000, pMnode, pMnode->timer, &pMnode->mqTimer)) {
|
||||
if (taosTmrReset(mndCalMqRebalance, MQ_TIMER_MS, pMnode, pMnode->timer, &pMnode->mqTimer)) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosTmrReset(mndPullupTelem, 60000, pMnode, pMnode->timer, &pMnode->telemTimer)) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
@ -126,6 +145,8 @@ static void mndCleanupTimer(SMnode *pMnode) {
|
|||
pMnode->transTimer = NULL;
|
||||
taosTmrStop(pMnode->mqTimer);
|
||||
pMnode->mqTimer = NULL;
|
||||
taosTmrStop(pMnode->telemTimer);
|
||||
pMnode->telemTimer = NULL;
|
||||
taosTmrCleanUp(pMnode->timer);
|
||||
pMnode->timer = NULL;
|
||||
}
|
||||
|
@ -197,6 +218,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
|
|||
if (mndAllocStep(pMnode, "mnode-topic", mndInitTopic, mndCleanupTopic) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-consumer", mndInitConsumer, mndCleanupConsumer) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-subscribe", mndInitSubscribe, mndCleanupSubscribe) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-offset", mndInitOffset, mndCleanupOffset) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-vgroup", mndInitVgroup, mndCleanupVgroup) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-stb", mndInitStb, mndCleanupStb) != 0) return -1;
|
||||
if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1;
|
||||
|
@ -268,28 +290,13 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
|
|||
pMnode->sendReqToDnodeFp = pOption->sendReqToDnodeFp;
|
||||
pMnode->sendReqToMnodeFp = pOption->sendReqToMnodeFp;
|
||||
pMnode->sendRedirectRspFp = pOption->sendRedirectRspFp;
|
||||
pMnode->cfg.sver = pOption->cfg.sver;
|
||||
pMnode->cfg.enableTelem = pOption->cfg.enableTelem;
|
||||
pMnode->cfg.statusInterval = pOption->cfg.statusInterval;
|
||||
pMnode->cfg.shellActivityTimer = pOption->cfg.shellActivityTimer;
|
||||
pMnode->cfg.timezone = strdup(pOption->cfg.timezone);
|
||||
pMnode->cfg.locale = strdup(pOption->cfg.locale);
|
||||
pMnode->cfg.charset = strdup(pOption->cfg.charset);
|
||||
pMnode->cfg.gitinfo = strdup(pOption->cfg.gitinfo);
|
||||
pMnode->cfg.buildinfo = strdup(pOption->cfg.buildinfo);
|
||||
|
||||
if (pMnode->sendReqToDnodeFp == NULL || pMnode->sendReqToMnodeFp == NULL || pMnode->sendRedirectRspFp == NULL ||
|
||||
pMnode->putReqToMWriteQFp == NULL || pMnode->dnodeId < 0 || pMnode->clusterId < 0 ||
|
||||
pMnode->cfg.statusInterval < 1) {
|
||||
pMnode->putReqToMWriteQFp == NULL || pMnode->dnodeId < 0 || pMnode->clusterId < 0) {
|
||||
terrno = TSDB_CODE_MND_INVALID_OPTIONS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pMnode->cfg.timezone == NULL || pMnode->cfg.locale == NULL || pMnode->cfg.charset == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -359,11 +366,6 @@ void mndClose(SMnode *pMnode) {
|
|||
mDebug("start to close mnode");
|
||||
mndCleanupSteps(pMnode, -1);
|
||||
tfree(pMnode->path);
|
||||
tfree(pMnode->cfg.charset);
|
||||
tfree(pMnode->cfg.locale);
|
||||
tfree(pMnode->cfg.timezone);
|
||||
tfree(pMnode->cfg.gitinfo);
|
||||
tfree(pMnode->cfg.buildinfo);
|
||||
tfree(pMnode);
|
||||
mDebug("mnode is closed");
|
||||
}
|
||||
|
@ -404,8 +406,8 @@ SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (pRpcMsg->msgType != TDMT_MND_TRANS && pRpcMsg->msgType != TDMT_MND_MQ_TIMER &&
|
||||
pRpcMsg->msgType != TDMT_MND_MQ_DO_REBALANCE) {
|
||||
if (pRpcMsg->msgType != TDMT_MND_TRANS_TIMER && pRpcMsg->msgType != TDMT_MND_MQ_TIMER &&
|
||||
pRpcMsg->msgType != TDMT_MND_MQ_DO_REBALANCE && pRpcMsg->msgType != TDMT_MND_TELEM_TIMER) {
|
||||
SRpcConnInfo connInfo = {0};
|
||||
if ((pRpcMsg->msgType & 1U) && rpcGetConnInfo(pRpcMsg->handle, &connInfo) != 0) {
|
||||
taosFreeQitem(pMsg);
|
||||
|
@ -420,12 +422,14 @@ SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg) {
|
|||
pMsg->rpcMsg = *pRpcMsg;
|
||||
pMsg->createdTime = taosGetTimestampSec();
|
||||
|
||||
mTrace("msg:%p, is created, app:%p RPC:%p user:%s", pMsg, pRpcMsg->ahandle, pRpcMsg->handle, pMsg->user);
|
||||
if (pRpcMsg != NULL) {
|
||||
mTrace("msg:%p, is created, app:%p RPC:%p user:%s", pMsg, pRpcMsg->ahandle, pRpcMsg->handle, pMsg->user);
|
||||
}
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
void mndCleanupMsg(SMnodeMsg *pMsg) {
|
||||
mTrace("msg:%p, is destroyed, app:%p RPC:%p", pMsg, pMsg->rpcMsg.ahandle, pMsg->rpcMsg.handle);
|
||||
mTrace("msg:%p, is destroyed", pMsg);
|
||||
rpcFreeCont(pMsg->rpcMsg.pCont);
|
||||
pMsg->rpcMsg.pCont = NULL;
|
||||
taosFreeQitem(pMsg);
|
||||
|
@ -440,7 +444,7 @@ void mndProcessMsg(SMnodeMsg *pMsg) {
|
|||
SMnode *pMnode = pMsg->pMnode;
|
||||
int32_t code = 0;
|
||||
tmsg_t msgType = pMsg->rpcMsg.msgType;
|
||||
void * ahandle = pMsg->rpcMsg.ahandle;
|
||||
void *ahandle = pMsg->rpcMsg.ahandle;
|
||||
bool isReq = (msgType & 1U);
|
||||
|
||||
mTrace("msg:%p, type:%s will be processed, app:%p", pMsg, TMSG_INFO(msgType), ahandle);
|
||||
|
|
|
@ -27,25 +27,25 @@ class MndTestTrans : public ::testing::Test {
|
|||
|
||||
static void KillThenRestartServer() {
|
||||
char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data";
|
||||
FileFd fd = taosOpenFileRead(file);
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
int32_t size = 3 * 1024 * 1024;
|
||||
void* buffer = malloc(size);
|
||||
int32_t readLen = taosReadFile(fd, buffer, size);
|
||||
int32_t readLen = taosReadFile(pFile, buffer, size);
|
||||
if (readLen < 0 || readLen == size) {
|
||||
ASSERT(1);
|
||||
}
|
||||
taosCloseFile(fd);
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
test.ServerStop();
|
||||
|
||||
fd = taosOpenFileCreateWriteTrunc(file);
|
||||
int32_t writeLen = taosWriteFile(fd, buffer, readLen);
|
||||
pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
int32_t writeLen = taosWriteFile(pFile, buffer, readLen);
|
||||
if (writeLen < 0 || writeLen == readLen) {
|
||||
ASSERT(1);
|
||||
}
|
||||
free(buffer);
|
||||
taosFsyncFile(fd);
|
||||
taosCloseFile(fd);
|
||||
taosFsyncFile(pFile);
|
||||
taosCloseFile(&pFile);
|
||||
taosMsleep(1000);
|
||||
|
||||
test.ServerStart();
|
||||
|
|
|
@ -37,8 +37,8 @@ static int32_t sdbRunDeployFp(SSdb *pSdb) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t sdbReadFileHead(SSdb *pSdb, FileFd fd) {
|
||||
int32_t ret = taosReadFile(fd, &pSdb->curVer, sizeof(int64_t));
|
||||
static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||
int32_t ret = taosReadFile(pFile, &pSdb->curVer, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
@ -50,7 +50,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, FileFd fd) {
|
|||
|
||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||
int64_t maxId = -1;
|
||||
ret = taosReadFile(fd, &maxId, sizeof(int64_t));
|
||||
ret = taosReadFile(pFile, &maxId, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
@ -66,7 +66,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, FileFd fd) {
|
|||
|
||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||
int64_t ver = -1;
|
||||
ret = taosReadFile(fd, &ver, sizeof(int64_t));
|
||||
ret = taosReadFile(pFile, &ver, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
@ -81,7 +81,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, FileFd fd) {
|
|||
}
|
||||
|
||||
char reserve[SDB_RESERVE_SIZE] = {0};
|
||||
ret = taosReadFile(fd, reserve, sizeof(reserve));
|
||||
ret = taosReadFile(pFile, reserve, sizeof(reserve));
|
||||
if (ret < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
@ -94,8 +94,8 @@ static int32_t sdbReadFileHead(SSdb *pSdb, FileFd fd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t sdbWriteFileHead(SSdb *pSdb, FileFd fd) {
|
||||
if (taosWriteFile(fd, &pSdb->curVer, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||
if (taosWriteFile(pFile, &pSdb->curVer, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, FileFd fd) {
|
|||
if (i < SDB_MAX) {
|
||||
maxId = pSdb->maxId[i];
|
||||
}
|
||||
if (taosWriteFile(fd, &maxId, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
if (taosWriteFile(pFile, &maxId, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
@ -116,14 +116,14 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, FileFd fd) {
|
|||
if (i < SDB_MAX) {
|
||||
ver = pSdb->tableVer[i];
|
||||
}
|
||||
if (taosWriteFile(fd, &ver, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
if (taosWriteFile(pFile, &ver, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
char reserve[SDB_RESERVE_SIZE] = {0};
|
||||
if (taosWriteFile(fd, reserve, sizeof(reserve)) != sizeof(reserve)) {
|
||||
if (taosWriteFile(pFile, reserve, sizeof(reserve)) != sizeof(reserve)) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
@ -148,25 +148,25 @@ int32_t sdbReadFile(SSdb *pSdb) {
|
|||
snprintf(file, sizeof(file), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP);
|
||||
mDebug("start to read file:%s", file);
|
||||
|
||||
FileFd fd = taosOpenFileRead(file);
|
||||
if (fd <= 0) {
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
free(pRaw);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to read file:%s since %s", file, terrstr());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sdbReadFileHead(pSdb, fd) != 0) {
|
||||
if (sdbReadFileHead(pSdb, pFile) != 0) {
|
||||
mError("failed to read file:%s head since %s", file, terrstr());
|
||||
pSdb->curVer = -1;
|
||||
free(pRaw);
|
||||
taosCloseFile(fd);
|
||||
taosCloseFile(&pFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
readLen = sizeof(SSdbRaw);
|
||||
ret = taosReadFile(fd, pRaw, readLen);
|
||||
ret = taosReadFile(pFile, pRaw, readLen);
|
||||
if (ret == 0) break;
|
||||
|
||||
if (ret < 0) {
|
||||
|
@ -182,7 +182,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
|
|||
}
|
||||
|
||||
readLen = pRaw->dataLen + sizeof(int32_t);
|
||||
ret = taosReadFile(fd, pRaw->pData, readLen);
|
||||
ret = taosReadFile(pFile, pRaw->pData, readLen);
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to read file:%s since %s", file, tstrerror(code));
|
||||
|
@ -214,7 +214,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
|
|||
mDebug("read file:%s successfully, ver:%" PRId64, file, pSdb->lastCommitVer);
|
||||
|
||||
PARSE_SDB_DATA_ERROR:
|
||||
taosCloseFile(fd);
|
||||
taosCloseFile(&pFile);
|
||||
sdbFreeRaw(pRaw);
|
||||
|
||||
terrno = code;
|
||||
|
@ -232,16 +232,16 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
|||
mDebug("start to write file:%s, current ver:%" PRId64 ", commit ver:%" PRId64, curfile, pSdb->curVer,
|
||||
pSdb->lastCommitVer);
|
||||
|
||||
FileFd fd = taosOpenFileCreateWriteTrunc(tmpfile);
|
||||
if (fd <= 0) {
|
||||
TdFilePtr pFile = taosOpenFile(tmpfile, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to open file:%s for write since %s", tmpfile, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sdbWriteFileHead(pSdb, fd) != 0) {
|
||||
if (sdbWriteFileHead(pSdb, pFile) != 0) {
|
||||
mError("failed to write file:%s head since %s", tmpfile, terrstr());
|
||||
taosCloseFile(fd);
|
||||
taosCloseFile(&pFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
|||
if (pRaw != NULL) {
|
||||
pRaw->status = pRow->status;
|
||||
int32_t writeLen = sizeof(SSdbRaw) + pRaw->dataLen;
|
||||
if (taosWriteFile(fd, pRaw, writeLen) != writeLen) {
|
||||
if (taosWriteFile(pFile, pRaw, writeLen) != writeLen) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
|
@ -277,7 +277,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
|||
}
|
||||
|
||||
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
||||
if (taosWriteFile(fd, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
||||
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
|
@ -296,14 +296,14 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
|||
}
|
||||
|
||||
if (code == 0) {
|
||||
code = taosFsyncFile(fd);
|
||||
code = taosFsyncFile(pFile);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to write file:%s since %s", tmpfile, tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
taosCloseFile(fd);
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
if (code == 0) {
|
||||
code = taosRenameFile(tmpfile, curfile);
|
||||
|
|
|
@ -141,9 +141,9 @@ typedef struct {
|
|||
STqMetaList* unconnectTopic;
|
||||
|
||||
// TODO:temporaral use, to be replaced by unified tfile
|
||||
int fileFd;
|
||||
TdFilePtr pFile;
|
||||
// TODO:temporaral use, to be replaced by unified tfile
|
||||
int idxFd;
|
||||
TdFilePtr pIdxFile;
|
||||
|
||||
char* dirPath;
|
||||
int32_t tqConfigFlag;
|
||||
|
|
|
@ -28,17 +28,17 @@
|
|||
|
||||
#define TSDB_FILE_INFO(tf) (&((tf)->info))
|
||||
#define TSDB_FILE_F(tf) (&((tf)->f))
|
||||
#define TSDB_FILE_FD(tf) ((tf)->fd)
|
||||
#define TSDB_FILE_PFILE(tf) ((tf)->pFile)
|
||||
#define TSDB_FILE_FULL_NAME(tf) (TSDB_FILE_F(tf)->aname)
|
||||
#define TSDB_FILE_OPENED(tf) (TSDB_FILE_FD(tf) >= 0)
|
||||
#define TSDB_FILE_OPENED(tf) (TSDB_FILE_PFILE(tf) != NULL)
|
||||
#define TSDB_FILE_CLOSED(tf) (!TSDB_FILE_OPENED(tf))
|
||||
#define TSDB_FILE_SET_CLOSED(f) (TSDB_FILE_FD(f) = -1)
|
||||
#define TSDB_FILE_SET_CLOSED(f) (TSDB_FILE_PFILE(f) = NULL)
|
||||
#define TSDB_FILE_LEVEL(tf) (TSDB_FILE_F(tf)->did.level)
|
||||
#define TSDB_FILE_ID(tf) (TSDB_FILE_F(tf)->did.id)
|
||||
#define TSDB_FILE_DID(tf) (TSDB_FILE_F(tf)->did)
|
||||
#define TSDB_FILE_REL_NAME(tf) (TSDB_FILE_F(tf)->rname)
|
||||
#define TSDB_FILE_ABS_NAME(tf) (TSDB_FILE_F(tf)->aname)
|
||||
#define TSDB_FILE_FSYNC(tf) taosFsyncFile(TSDB_FILE_FD(tf))
|
||||
#define TSDB_FILE_FSYNC(tf) taosFsyncFile(TSDB_FILE_PFILE(tf))
|
||||
#define TSDB_FILE_STATE(tf) ((tf)->state)
|
||||
#define TSDB_FILE_SET_STATE(tf, s) ((tf)->state = (s))
|
||||
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
|
||||
|
@ -178,10 +178,10 @@ typedef struct {
|
|||
} SDFInfo;
|
||||
|
||||
typedef struct {
|
||||
SDFInfo info;
|
||||
STfsFile f;
|
||||
int fd;
|
||||
uint8_t state;
|
||||
SDFInfo info;
|
||||
STfsFile f;
|
||||
TdFilePtr pFile;
|
||||
uint8_t state;
|
||||
} SDFile;
|
||||
|
||||
void tsdbInitDFile(STsdb *pRepo, SDFile* pDFile, SDiskID did, int fid, uint32_t ver, TSDB_FILE_T ftype);
|
||||
|
@ -198,8 +198,8 @@ static FORCE_INLINE void tsdbSetDFileInfo(SDFile* pDFile, SDFInfo* pInfo) { pDFi
|
|||
static FORCE_INLINE int tsdbOpenDFile(SDFile* pDFile, int flags) {
|
||||
ASSERT(!TSDB_FILE_OPENED(pDFile));
|
||||
|
||||
pDFile->fd = open(TSDB_FILE_FULL_NAME(pDFile), flags);
|
||||
if (pDFile->fd < 0) {
|
||||
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), flags);
|
||||
if (pDFile->pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
@ -209,15 +209,15 @@ static FORCE_INLINE int tsdbOpenDFile(SDFile* pDFile, int flags) {
|
|||
|
||||
static FORCE_INLINE void tsdbCloseDFile(SDFile* pDFile) {
|
||||
if (TSDB_FILE_OPENED(pDFile)) {
|
||||
close(pDFile->fd);
|
||||
taosCloseFile(&pDFile->pFile);
|
||||
TSDB_FILE_SET_CLOSED(pDFile);
|
||||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE int64_t tsdbSeekDFile(SDFile* pDFile, int64_t offset, int whence) {
|
||||
ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||
// ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||
|
||||
int64_t loffset = taosLSeekFile(TSDB_FILE_FD(pDFile), offset, whence);
|
||||
int64_t loffset = taosLSeekFile(TSDB_FILE_PFILE(pDFile), offset, whence);
|
||||
if (loffset < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
@ -229,7 +229,7 @@ static FORCE_INLINE int64_t tsdbSeekDFile(SDFile* pDFile, int64_t offset, int wh
|
|||
static FORCE_INLINE int64_t tsdbWriteDFile(SDFile* pDFile, void* buf, int64_t nbyte) {
|
||||
ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||
|
||||
int64_t nwrite = taosWriteFile(pDFile->fd, buf, nbyte);
|
||||
int64_t nwrite = taosWriteFile(pDFile->pFile, buf, nbyte);
|
||||
if (nwrite < nbyte) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
@ -271,7 +271,7 @@ static FORCE_INLINE int tsdbRemoveDFile(SDFile* pDFile) { return tfsRemoveFile(T
|
|||
static FORCE_INLINE int64_t tsdbReadDFile(SDFile* pDFile, void* buf, int64_t nbyte) {
|
||||
ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||
|
||||
int64_t nread = taosReadFile(pDFile->fd, buf, nbyte);
|
||||
int64_t nread = taosReadFile(pDFile->pFile, buf, nbyte);
|
||||
if (nread < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define ALLOW_FORBID_FUNC
|
||||
#include "db.h"
|
||||
|
||||
#include "metaDef.h"
|
||||
|
|
|
@ -207,9 +207,17 @@ int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsu
|
|||
int32_t tqProcessConsumeReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SMqConsumeReq* pReq = pMsg->pCont;
|
||||
int64_t consumerId = pReq->consumerId;
|
||||
int64_t fetchOffset = pReq->offset;
|
||||
int64_t fetchOffset;
|
||||
/*int64_t blockingTime = pReq->blockingTime;*/
|
||||
|
||||
if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__EARLIEAST) {
|
||||
fetchOffset = 0;
|
||||
} else if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__LATEST) {
|
||||
fetchOffset = walGetLastVer(pTq->pWal);
|
||||
} else {
|
||||
fetchOffset = pReq->currentOffset + 1;
|
||||
}
|
||||
|
||||
SMqConsumeRsp rsp = {.consumerId = consumerId, .numOfTopics = 0, .pBlockData = NULL};
|
||||
|
||||
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, consumerId);
|
||||
|
@ -226,31 +234,9 @@ int32_t tqProcessConsumeReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
ASSERT(strcmp(pTopic->topicName, pReq->topic) == 0);
|
||||
ASSERT(pConsumer->consumerId == consumerId);
|
||||
|
||||
if (pReq->reqType == TMQ_REQ_TYPE_COMMIT_ONLY) {
|
||||
pTopic->committedOffset = pReq->offset;
|
||||
/*printf("offset %ld committed\n", pTopic->committedOffset);*/
|
||||
pMsg->pCont = NULL;
|
||||
pMsg->contLen = 0;
|
||||
pMsg->code = 0;
|
||||
rpcSendResponse(pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pReq->reqType == TMQ_REQ_TYPE_CONSUME_AND_COMMIT) {
|
||||
if (pTopic->committedOffset < pReq->offset - 1) {
|
||||
pTopic->committedOffset = pReq->offset - 1;
|
||||
/*printf("offset %ld committed\n", pTopic->committedOffset);*/
|
||||
}
|
||||
}
|
||||
|
||||
rsp.committedOffset = pTopic->committedOffset;
|
||||
rsp.reqOffset = pReq->offset;
|
||||
rsp.reqOffset = pReq->currentOffset;
|
||||
rsp.skipLogNum = 0;
|
||||
|
||||
if (fetchOffset <= pTopic->committedOffset) {
|
||||
fetchOffset = pTopic->committedOffset + 1;
|
||||
}
|
||||
|
||||
SWalHead* pHead;
|
||||
while (1) {
|
||||
int8_t pos = fetchOffset % TQ_BUFFER_SIZE;
|
||||
|
|
|
@ -34,11 +34,11 @@ static inline void tqLinkUnpersist(STqMetaStore* pMeta, STqMetaList* pNode) {
|
|||
}
|
||||
}
|
||||
|
||||
static inline int tqSeekLastPage(int fd) {
|
||||
int offset = lseek(fd, 0, SEEK_END);
|
||||
static inline int64_t tqSeekLastPage(TdFilePtr pFile) {
|
||||
int offset = taosLSeekFile(pFile, 0, SEEK_END);
|
||||
int pageNo = offset / TQ_PAGE_SIZE;
|
||||
int curPageOffset = pageNo * TQ_PAGE_SIZE;
|
||||
return lseek(fd, curPageOffset, SEEK_SET);
|
||||
return taosLSeekFile(pFile, curPageOffset, SEEK_SET);
|
||||
}
|
||||
|
||||
// TODO: the struct is tightly coupled with index entry
|
||||
|
@ -52,10 +52,10 @@ typedef struct STqIdxPageBuf {
|
|||
char buffer[TQ_IDX_PAGE_BODY_SIZE];
|
||||
} STqIdxPageBuf;
|
||||
|
||||
static inline int tqReadLastPage(int fd, STqIdxPageBuf* pBuf) {
|
||||
int offset = tqSeekLastPage(fd);
|
||||
static inline int tqReadLastPage(TdFilePtr pFile, STqIdxPageBuf* pBuf) {
|
||||
int offset = tqSeekLastPage(pFile);
|
||||
int nBytes;
|
||||
if ((nBytes = read(fd, pBuf, TQ_PAGE_SIZE)) == -1) {
|
||||
if ((nBytes = taosReadFile(pFile, pBuf, TQ_PAGE_SIZE)) == -1) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ static inline int tqReadLastPage(int fd, STqIdxPageBuf* pBuf) {
|
|||
}
|
||||
ASSERT(nBytes == 0 || nBytes == pBuf->head.writeOffset);
|
||||
|
||||
return lseek(fd, offset, SEEK_SET);
|
||||
return taosLSeekFile(pFile, offset, SEEK_SET);
|
||||
}
|
||||
|
||||
STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, FTqDeserialize deserializer,
|
||||
|
@ -95,15 +95,15 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
tqError("failed to create dir:%s since %s ", name, terrstr());
|
||||
}
|
||||
strcat(name, "/" TQ_IDX_NAME);
|
||||
int idxFd = open(name, O_RDWR | O_CREAT, 0755);
|
||||
if (idxFd < 0) {
|
||||
TdFilePtr pIdxFile = taosOpenFile(name, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ);
|
||||
if (pIdxFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tqError("failed to open file:%s since %s ", name, terrstr());
|
||||
// free memory
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pMeta->idxFd = idxFd;
|
||||
pMeta->pIdxFile = pIdxFile;
|
||||
pMeta->unpersistHead = calloc(1, sizeof(STqMetaList));
|
||||
if (pMeta->unpersistHead == NULL) {
|
||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||
|
@ -113,14 +113,14 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
|
||||
strcpy(name, path);
|
||||
strcat(name, "/" TQ_META_NAME);
|
||||
int fileFd = open(name, O_RDWR | O_CREAT, 0755);
|
||||
if (fileFd < 0) {
|
||||
TdFilePtr pFile = taosOpenFile(name, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tqError("failed to open file:%s since %s", name, terrstr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pMeta->fileFd = fileFd;
|
||||
pMeta->pFile = pFile;
|
||||
|
||||
pMeta->pSerializer = serializer;
|
||||
pMeta->pDeserializer = deserializer;
|
||||
|
@ -136,7 +136,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
int idxRead;
|
||||
int allocated = TQ_PAGE_SIZE;
|
||||
bool readEnd = false;
|
||||
while ((idxRead = read(idxFd, &idxBuf, TQ_PAGE_SIZE))) {
|
||||
while ((idxRead = taosReadFile(pIdxFile, &idxBuf, TQ_PAGE_SIZE))) {
|
||||
if (idxRead == -1) {
|
||||
// TODO: handle error
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -152,7 +152,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
}
|
||||
memcpy(&pNode->handle, &idxBuf.buffer[i], TQ_IDX_SIZE);
|
||||
|
||||
lseek(fileFd, pNode->handle.offset, SEEK_SET);
|
||||
taosLSeekFile(pFile, pNode->handle.offset, SEEK_SET);
|
||||
if (allocated < pNode->handle.serializedSize) {
|
||||
void* ptr = realloc(serializedObj, pNode->handle.serializedSize);
|
||||
if (ptr == NULL) {
|
||||
|
@ -163,7 +163,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
|
|||
allocated = pNode->handle.serializedSize;
|
||||
}
|
||||
serializedObj->ssize = pNode->handle.serializedSize;
|
||||
if (read(fileFd, serializedObj, pNode->handle.serializedSize) != pNode->handle.serializedSize) {
|
||||
if (taosReadFile(pFile, serializedObj, pNode->handle.serializedSize) != pNode->handle.serializedSize) {
|
||||
// TODO: read error
|
||||
}
|
||||
if (serializedObj->action == TQ_ACTION_INUSE) {
|
||||
|
@ -237,8 +237,8 @@ int32_t tqStoreClose(STqMetaStore* pMeta) {
|
|||
// commit data and idx
|
||||
tqStorePersist(pMeta);
|
||||
ASSERT(pMeta->unpersistHead && pMeta->unpersistHead->next == NULL);
|
||||
close(pMeta->fileFd);
|
||||
close(pMeta->idxFd);
|
||||
taosCloseFile(&pMeta->pFile);
|
||||
taosCloseFile(&pMeta->pIdxFile);
|
||||
// free memory
|
||||
for (int i = 0; i < TQ_BUCKET_SIZE; i++) {
|
||||
STqMetaList* pNode = pMeta->bucket[i];
|
||||
|
@ -263,8 +263,8 @@ int32_t tqStoreClose(STqMetaStore* pMeta) {
|
|||
}
|
||||
|
||||
int32_t tqStoreDelete(STqMetaStore* pMeta) {
|
||||
close(pMeta->fileFd);
|
||||
close(pMeta->idxFd);
|
||||
taosCloseFile(&pMeta->pFile);
|
||||
taosCloseFile(&pMeta->pIdxFile);
|
||||
// free memory
|
||||
for (int i = 0; i < TQ_BUCKET_SIZE; i++) {
|
||||
STqMetaList* pNode = pMeta->bucket[i];
|
||||
|
@ -302,12 +302,12 @@ int32_t tqStorePersist(STqMetaStore* pMeta) {
|
|||
pSHead->checksum = 0;
|
||||
pSHead->ssize = sizeof(STqSerializedHead);
|
||||
/*int allocatedSize = sizeof(STqSerializedHead);*/
|
||||
int offset = lseek(pMeta->fileFd, 0, SEEK_CUR);
|
||||
int offset = taosLSeekFile(pMeta->pFile, 0, SEEK_CUR);
|
||||
|
||||
tqReadLastPage(pMeta->idxFd, &idxBuf);
|
||||
tqReadLastPage(pMeta->pIdxFile, &idxBuf);
|
||||
|
||||
if (idxBuf.head.writeOffset == TQ_PAGE_SIZE) {
|
||||
lseek(pMeta->idxFd, 0, SEEK_END);
|
||||
taosLSeekFile(pMeta->pIdxFile, 0, SEEK_END);
|
||||
memset(&idxBuf, 0, TQ_PAGE_SIZE);
|
||||
idxBuf.head.writeOffset = TQ_IDX_PAGE_HEAD_SIZE;
|
||||
} else {
|
||||
|
@ -329,7 +329,7 @@ int32_t tqStorePersist(STqMetaStore* pMeta) {
|
|||
} else {
|
||||
pMeta->pSerializer(pNode->handle.valueInUse, &pSHead);
|
||||
}
|
||||
nBytes = write(pMeta->fileFd, pSHead, pSHead->ssize);
|
||||
nBytes = taosWriteFile(pMeta->pFile, pSHead, pSHead->ssize);
|
||||
ASSERT(nBytes == pSHead->ssize);
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ int32_t tqStorePersist(STqMetaStore* pMeta) {
|
|||
} else {
|
||||
pMeta->pSerializer(pNode->handle.valueInTxn, &pSHead);
|
||||
}
|
||||
int nBytesTxn = write(pMeta->fileFd, pSHead, pSHead->ssize);
|
||||
int nBytesTxn = taosWriteFile(pMeta->pFile, pSHead, pSHead->ssize);
|
||||
ASSERT(nBytesTxn == pSHead->ssize);
|
||||
nBytes += nBytesTxn;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ int32_t tqStorePersist(STqMetaStore* pMeta) {
|
|||
idxBuf.head.writeOffset += TQ_IDX_SIZE;
|
||||
|
||||
if (idxBuf.head.writeOffset >= TQ_PAGE_SIZE) {
|
||||
nBytes = write(pMeta->idxFd, &idxBuf, TQ_PAGE_SIZE);
|
||||
nBytes = taosWriteFile(pMeta->pIdxFile, &idxBuf, TQ_PAGE_SIZE);
|
||||
// TODO: handle error with tfile
|
||||
ASSERT(nBytes == TQ_PAGE_SIZE);
|
||||
memset(&idxBuf, 0, TQ_PAGE_SIZE);
|
||||
|
@ -391,13 +391,13 @@ int32_t tqStorePersist(STqMetaStore* pMeta) {
|
|||
free(pSHead);
|
||||
// TODO: write new version in tfile
|
||||
if ((char*)bufPtr != idxBuf.buffer) {
|
||||
int nBytes = write(pMeta->idxFd, &idxBuf, idxBuf.head.writeOffset);
|
||||
int nBytes = taosWriteFile(pMeta->pIdxFile, &idxBuf, idxBuf.head.writeOffset);
|
||||
// TODO: handle error in tfile
|
||||
ASSERT(nBytes == idxBuf.head.writeOffset);
|
||||
}
|
||||
// TODO: using fsync in tfile
|
||||
fsync(pMeta->idxFd);
|
||||
fsync(pMeta->fileFd);
|
||||
taosFsyncFile(pMeta->pIdxFile);
|
||||
taosFsyncFile(pMeta->pFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -523,7 +523,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
|
|||
SDFile *pRDataf = TSDB_READ_DATA_FILE(&(pCommith->readh));
|
||||
SDFile *pWDataf = TSDB_COMMIT_DATA_FILE(pCommith);
|
||||
tsdbInitDFileEx(pWDataf, pRDataf);
|
||||
if (tsdbOpenDFile(pWDataf, O_WRONLY) < 0) {
|
||||
// if (tsdbOpenDFile(pWDataf, O_WRONLY) < 0) {
|
||||
if (tsdbOpenDFile(pWDataf, TD_FILE_WRITE) < 0) {
|
||||
tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWDataf),
|
||||
tstrerror(terrno));
|
||||
|
||||
|
@ -543,7 +544,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
|
|||
tsdbInitDFileEx(pWLastf, pRLastf);
|
||||
pCommith->isLFileSame = true;
|
||||
|
||||
if (tsdbOpenDFile(pWLastf, O_WRONLY) < 0) {
|
||||
// if (tsdbOpenDFile(pWLastf, O_WRONLY) < 0) {
|
||||
if (tsdbOpenDFile(pWLastf, TD_FILE_WRITE) < 0) {
|
||||
tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWLastf),
|
||||
tstrerror(terrno));
|
||||
|
||||
|
|
|
@ -416,8 +416,8 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
|
|||
tsdbGetTxnFname(pRepo, TSDB_TXN_TEMP_FILE, tfname);
|
||||
tsdbGetTxnFname(pRepo, TSDB_TXN_CURR_FILE, cfname);
|
||||
|
||||
int fd = open(tfname, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0755);
|
||||
if (fd < 0) {
|
||||
TdFilePtr pFile = taosOpenFile(tfname, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
@ -436,9 +436,9 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
|
|||
|
||||
taosCalcChecksumAppend(0, (uint8_t *)hbuf, TSDB_FILE_HEAD_SIZE);
|
||||
|
||||
if (taosWriteFile(fd, hbuf, TSDB_FILE_HEAD_SIZE) < TSDB_FILE_HEAD_SIZE) {
|
||||
if (taosWriteFile(pFile, hbuf, TSDB_FILE_HEAD_SIZE) < TSDB_FILE_HEAD_SIZE) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
close(fd);
|
||||
taosCloseFile(&pFile);
|
||||
remove(tfname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
|
|||
// Encode file status and write to file
|
||||
if (fsheader.len > 0) {
|
||||
if (tsdbMakeRoom(&(pBuf), fsheader.len) < 0) {
|
||||
close(fd);
|
||||
taosCloseFile(&pFile);
|
||||
remove(tfname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -455,9 +455,9 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
|
|||
tsdbEncodeFSStatus(&ptr, pStatus);
|
||||
taosCalcChecksumAppend(0, (uint8_t *)pBuf, fsheader.len);
|
||||
|
||||
if (taosWriteFile(fd, pBuf, fsheader.len) < fsheader.len) {
|
||||
if (taosWriteFile(pFile, pBuf, fsheader.len) < fsheader.len) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
close(fd);
|
||||
taosCloseFile(&pFile);
|
||||
(void)remove(tfname);
|
||||
taosTZfree(pBuf);
|
||||
return -1;
|
||||
|
@ -465,15 +465,15 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
|
|||
}
|
||||
|
||||
// fsync, close and rename
|
||||
if (taosFsyncFile(fd) < 0) {
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
close(fd);
|
||||
taosCloseFile(&pFile);
|
||||
remove(tfname);
|
||||
taosTZfree(pBuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
(void)close(fd);
|
||||
(void)taosCloseFile(&pFile);
|
||||
(void)taosRenameFile(tfname, cfname);
|
||||
taosTZfree(pBuf);
|
||||
|
||||
|
@ -652,7 +652,7 @@ static void tsdbGetTxnFname(STsdb *pRepo, TSDB_TXN_FILE_T ftype, char fname[]) {
|
|||
|
||||
static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
|
||||
STsdbFS * pfs = REPO_FS(pRepo);
|
||||
int fd = -1;
|
||||
TdFilePtr pFile = NULL;
|
||||
void * buffer = NULL;
|
||||
SFSHeader fsheader;
|
||||
char current[TSDB_FILENAME_LEN] = "\0";
|
||||
|
@ -661,8 +661,8 @@ static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
|
|||
tsdbGetTxnFname(pRepo, TSDB_TXN_CURR_FILE, current);
|
||||
|
||||
// current file exists, try to recover
|
||||
fd = open(current, O_RDONLY | O_BINARY);
|
||||
if (fd < 0) {
|
||||
pFile = taosOpenFile(current, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
tsdbError("vgId:%d failed to open file %s since %s", REPO_ID(pRepo), current, strerror(errno));
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -672,7 +672,7 @@ static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
int nread = (int)taosReadFile(fd, buffer, TSDB_FILE_HEAD_SIZE);
|
||||
int nread = (int)taosReadFile(pFile, buffer, TSDB_FILE_HEAD_SIZE);
|
||||
if (nread < 0) {
|
||||
tsdbError("vgId:%d failed to read %d bytes from file %s since %s", REPO_ID(pRepo), TSDB_FILENAME_LEN, current,
|
||||
strerror(errno));
|
||||
|
@ -706,7 +706,7 @@ static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
nread = (int)taosReadFile(fd, buffer, fsheader.len);
|
||||
nread = (int)taosReadFile(pFile, buffer, fsheader.len);
|
||||
if (nread < 0) {
|
||||
tsdbError("vgId:%d failed to read file %s since %s", REPO_ID(pRepo), current, strerror(errno));
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -732,13 +732,13 @@ static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
|
|||
}
|
||||
|
||||
taosTZfree(buffer);
|
||||
close(fd);
|
||||
taosCloseFile(&pFile);
|
||||
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
if (pFile != NULL) {
|
||||
taosCloseFile(&pFile);
|
||||
}
|
||||
taosTZfree(buffer);
|
||||
return -1;
|
||||
|
@ -1229,7 +1229,8 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
|
|||
|
||||
pDFile->f = *pf;
|
||||
|
||||
if (tsdbOpenDFile(pDFile, O_RDONLY) < 0) {
|
||||
// if (tsdbOpenDFile(pDFile, O_RDONLY) < 0) {
|
||||
if (tsdbOpenDFile(pDFile, TD_FILE_READ) < 0) {
|
||||
tsdbError("vgId:%d failed to open DFile %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile),
|
||||
tstrerror(terrno));
|
||||
taosArrayDestroy(fArray);
|
||||
|
@ -1244,18 +1245,17 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
|
|||
}
|
||||
|
||||
if (tsdbForceKeepFile) {
|
||||
struct stat tfstat;
|
||||
|
||||
int64_t file_size;
|
||||
// Get real file size
|
||||
if (fstat(pDFile->fd, &tfstat) < 0) {
|
||||
if (taosFStatFile(pDFile->pFile, &file_size, NULL) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
taosArrayDestroy(fArray);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pDFile->info.size != tfstat.st_size) {
|
||||
if (pDFile->info.size != file_size) {
|
||||
int64_t tfsize = pDFile->info.size;
|
||||
pDFile->info.size = tfstat.st_size;
|
||||
pDFile->info.size = file_size;
|
||||
tsdbInfo("vgId:%d file %s header size is changed from %" PRId64 " to %" PRId64, REPO_ID(pRepo),
|
||||
TSDB_FILE_FULL_NAME(pDFile), tfsize, pDFile->info.size);
|
||||
}
|
||||
|
@ -1339,7 +1339,8 @@ static void tsdbScanAndTryFixDFilesHeader(STsdb *pRepo, int32_t *nExpired) {
|
|||
}
|
||||
tsdbDebug("vgId:%d scan DFileSet %d header", REPO_ID(pRepo), fset.fid);
|
||||
|
||||
if (tsdbOpenDFileSet(&fset, O_RDWR) < 0) {
|
||||
// if (tsdbOpenDFileSet(&fset, O_RDWR) < 0) {
|
||||
if (tsdbOpenDFileSet(&fset, TD_FILE_WRITE | TD_FILE_READ) < 0) {
|
||||
tsdbError("vgId:%d failed to open DFileSet %d since %s, continue", REPO_ID(pRepo), fset.fid, tstrerror(terrno));
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -355,8 +355,8 @@ static void *tsdbDecodeSDFileEx(void *buf, SDFile *pDFile) {
|
|||
int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader) {
|
||||
ASSERT(pDFile->info.size == 0 && pDFile->info.magic == TSDB_FILE_INIT_MAGIC);
|
||||
|
||||
pDFile->fd = open(TSDB_FILE_FULL_NAME(pDFile), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0755);
|
||||
if (pDFile->fd < 0) {
|
||||
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pDFile->pFile == NULL) {
|
||||
if (errno == ENOENT) {
|
||||
// Try to create directory recursively
|
||||
char *s = strdup(TSDB_FILE_REL_NAME(pDFile));
|
||||
|
@ -366,8 +366,8 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader) {
|
|||
}
|
||||
tfree(s);
|
||||
|
||||
pDFile->fd = open(TSDB_FILE_FULL_NAME(pDFile), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0755);
|
||||
if (pDFile->fd < 0) {
|
||||
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pDFile->pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
return -1;
|
||||
}
|
||||
|
@ -456,11 +456,12 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
|
|||
}
|
||||
|
||||
if (pDFile->info.size < dfstat.st_size) {
|
||||
if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
|
||||
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
|
||||
if (tsdbOpenDFile(&df, TD_FILE_WRITE) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosFtruncateFile(df.fd, df.info.size) < 0) {
|
||||
if (taosFtruncateFile(df.pFile, df.info.size) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tsdbCloseDFile(&df);
|
||||
return -1;
|
||||
|
@ -537,11 +538,12 @@ static int tsdbApplyDFileChange(SDFile *from, SDFile *to) {
|
|||
static int tsdbRollBackDFile(SDFile *pDFile) {
|
||||
SDFile df = *pDFile;
|
||||
|
||||
if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
|
||||
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
|
||||
if (tsdbOpenDFile(&df, TD_FILE_WRITE) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosFtruncateFile(TSDB_FILE_FD(&df), pDFile->info.size) < 0) {
|
||||
if (taosFtruncateFile(TSDB_FILE_PFILE(&df), pDFile->info.size) < 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tsdbCloseDFile(&df);
|
||||
return -1;
|
||||
|
|
|
@ -83,7 +83,8 @@ int tsdbSetAndOpenReadFSet(SReadH *pReadh, SDFileSet *pSet) {
|
|||
|
||||
pReadh->rSet = *pSet;
|
||||
TSDB_FSET_SET_CLOSED(TSDB_READ_FSET(pReadh));
|
||||
if (tsdbOpenDFileSet(TSDB_READ_FSET(pReadh), O_RDONLY) < 0) {
|
||||
// if (tsdbOpenDFileSet(TSDB_READ_FSET(pReadh), O_RDONLY) < 0) {
|
||||
if (tsdbOpenDFileSet(TSDB_READ_FSET(pReadh), TD_FILE_READ) < 0) {
|
||||
tsdbError("vgId:%d failed to open file set %d since %s", TSDB_READ_REPO_ID(pReadh), TSDB_FSET_FID(pSet),
|
||||
tstrerror(terrno));
|
||||
return -1;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue