Skip to content

Commit

Permalink
Merge pull request #813 from taosdata/fix/TD-32823-3.0
Browse files Browse the repository at this point in the history
enh: support retry after sleep
  • Loading branch information
zitsen authored Nov 26, 2024
2 parents 8baf16e + 6816d63 commit 4f14fab
Show file tree
Hide file tree
Showing 11 changed files with 3,560 additions and 2,909 deletions.
523 changes: 523 additions & 0 deletions inc/dump.h

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions inc/dumpUtil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#ifndef INC_DUMPUTIL_H_
#define INC_DUMPUTIL_H_

#include <taos.h>
#include <taoserror.h>
#include <toolsdef.h>

//
// ------------ error code range defin ------------
//

// engine can retry code range
#define TSDB_CODE_RPC_BEGIN TSDB_CODE_RPC_NETWORK_UNAVAIL
#define TSDB_CODE_RPC_END TSDB_CODE_RPC_ASYNC_MODULE_QUIT

// websocket can retry code range
// range1 [0x0001~0x00FF]
#define WEBSOCKET_CODE_BEGIN1 0x0001
#define WEBSOCKET_CODE_END1 0x00FF
// range2 [0x0001~0x00FF]
#define WEBSOCKET_CODE_BEGIN2 0xE000
#define WEBSOCKET_CODE_END2 0xE0FF

//
// encapsulate the api of calling engine
//
#define RETRY_TYPE_CONNECT 0
#define RETRY_TYPE_QUERY 1
#define RETRY_TYPE_FETCH 2

//come from TDengine util/tdef.h
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string

//
// ------------- struct define ----------
//

// single link
typedef struct SNode {
char name[TSDB_TABLE_NAME_LEN];
struct SNode *next;
}SNode;


// return true to do retry , false no retry , code is error code
bool canRetry(int32_t code, int8_t type);

// single linked list

// malloc new node
SNode *mallocNode(const char* name, int32_t len);

// free nodes
void freeNodes(SNode* head);



//
// --------------- native ------------------
//


// connect
TAOS *taosConnect(const char *dbName);
// query
TAOS_RES *taosQuery(TAOS *taos, const char *sql, int32_t *code);


//
// --------------- websocket ------------------
//
#ifdef WEBSOCKET
// ws connect
WS_TAOS *wsConnect();
// ws query
WS_RES *wsQuery(WS_TAOS **ws_taos, const char *sql, int32_t *code);
// ws fetch
int32_t wsFetchBlock(WS_RES *rs, const void **pData, int32_t *numOfRows);

#endif


#endif // INC_DUMPUTIL_H_
42 changes: 42 additions & 0 deletions inc/wsdump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef INC_WSDUMP_H_
#define INC_WSDUMP_H_

//
// --------------- websocket ------------------
//

#ifdef WEBSOCKET

#include <taoserror.h>
#include <taosws.h>
#include <toolsdef.h>

int cleanIfQueryFailedWS(const char *funcname, int lineno, char *command, WS_RES *res);
int getTableRecordInfoWS(char *dbName, char *table, TableRecordInfo *pTableRecordInfo);
int getDbCountWS(WS_RES *ws_res);
int64_t getNtbCountOfStbWS(char *dbName, const char *stbName);
int getTableDesFromStbWS(WS_TAOS **taos_v, const char *dbName, const TableDes *stbTableDes, const char *table,
TableDes **ppTableDes);
int getTableDesWS(WS_TAOS **taos_v, const char *dbName, const char *table, TableDes *tableDes, const bool colOnly);
int64_t queryDbForDumpOutCountWS(char *command, WS_TAOS **taos_v, const char *dbName, const char *tbName,
const int precision);
TAOS_RES *queryDbForDumpOutOffsetWS(WS_TAOS **taos_v, char *command);
int64_t dumpTableDataAvroWS(char *dataFilename, int64_t index, const char *tbName, const bool belongStb,
const char *dbName, const int precision, int colCount, TableDes *tableDes,
int64_t start_time, int64_t end_time);
int64_t fillTbNameArrWS(WS_TAOS **taos_v, char *command, char **tbNameArr, const char *stable, const int64_t preCount);
int readNextTableDesWS(void *ws_res, TableDes *tbDes, int *idx, int *cnt);
void dumpExtraInfoVarWS(void **taos_v, FILE *fp);
int queryDbImplWS(WS_TAOS *taos_v, char *command);
void dumpNormalTablesOfStbWS(threadInfo *pThreadInfo, FILE *fp, char *dumpFilename);
int64_t dumpStbAndChildTbOfDbWS(WS_TAOS **taos_v, SDbInfo *dbInfo, FILE *fpDbs);
int64_t dumpNTablesOfDbWS(WS_TAOS **taos_v, SDbInfo *dbInfo);
int fillDbInfoWS(void **taos_v);
bool jointCloudDsn();
bool splitCloudDsn();
int64_t dumpTableDataWS(const int64_t index, FILE *fp, const char *tbName, const char *dbName, const int precision,
TableDes *tableDes, const int64_t start_time, const int64_t end_time);
int32_t readRowWS(void *res, int32_t idx, int32_t col, uint32_t *len, char **data);
#endif

#endif // INC_WSDUMP_H_
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin
SET_PROPERTY(TARGET snappy PROPERTY IMPORTED_LOCATION
"${CMAKE_BINARY_DIR}/build/lib/libsnappy.a")

ADD_EXECUTABLE(taosdump taosdump.c toolstime.c toolsSys.c toolsDir.c toolsString.c)
ADD_EXECUTABLE(taosdump taosdump.c dumpUtil.c wsdump.c toolstime.c toolsSys.c toolsDir.c toolsString.c)
ADD_DEPENDENCIES(deps-snappy apache-avro)
ADD_DEPENDENCIES(taosdump deps-jansson)
ADD_DEPENDENCIES(taosdump deps-snappy)
Expand Down Expand Up @@ -446,7 +446,7 @@ ELSE ()
ADD_EXECUTABLE(taosBenchmark benchMain.c benchLog.c benchSubscribe.c benchQuery.c benchCsv.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ENDIF ()

ADD_EXECUTABLE(taosdump taosdump.c toolsSys.c toolstime.c toolsDir.c toolsString.c)
ADD_EXECUTABLE(taosdump taosdump.c dumpUtil.c wsdump.c toolsSys.c toolstime.c toolsDir.c toolsString.c)
ADD_DEPENDENCIES(apache-avro tools-zlib)
ADD_DEPENDENCIES(apache-avro deps-jansson)
ADD_DEPENDENCIES(apache-avro deps-snappy)
Expand Down
Loading

0 comments on commit 4f14fab

Please sign in to comment.