test:merge 3.0
This commit is contained in:
parent
b25442a2fc
commit
4bc09c22ad
|
@ -22,9 +22,9 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
#include "taosdef.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "taosdef.h"
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define GREEN "\033[1;32m"
|
#define GREEN "\033[1;32m"
|
||||||
|
@ -36,11 +36,7 @@
|
||||||
#define MAX_CONSUMER_THREAD_CNT (16)
|
#define MAX_CONSUMER_THREAD_CNT (16)
|
||||||
#define MAX_VGROUP_CNT (32)
|
#define MAX_VGROUP_CNT (32)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { NOTIFY_CMD_START_CONSUM, NOTIFY_CMD_START_COMMIT, NOTIFY_CMD_ID_BUTT } NOTIFY_CMD_ID;
|
||||||
NOTIFY_CMD_START_CONSUM,
|
|
||||||
NOTIFY_CMD_START_COMMIT,
|
|
||||||
NOTIFY_CMD_ID_BUTT
|
|
||||||
}NOTIFY_CMD_ID;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
TdThread thread;
|
TdThread thread;
|
||||||
|
@ -89,6 +85,7 @@ typedef struct {
|
||||||
int32_t saveRowFlag;
|
int32_t saveRowFlag;
|
||||||
int32_t consumeDelay; // unit s
|
int32_t consumeDelay; // unit s
|
||||||
int32_t numOfThread;
|
int32_t numOfThread;
|
||||||
|
int32_t useSnapshot;
|
||||||
SThreadInfo stThreads[MAX_CONSUMER_THREAD_CNT];
|
SThreadInfo stThreads[MAX_CONSUMER_THREAD_CNT];
|
||||||
} SConfInfo;
|
} SConfInfo;
|
||||||
|
|
||||||
|
@ -217,6 +214,8 @@ void parseArgument(int32_t argc, char* argv[]) {
|
||||||
g_stConfInfo.saveRowFlag = atol(argv[++i]);
|
g_stConfInfo.saveRowFlag = atol(argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-y") == 0) {
|
} else if (strcmp(argv[i], "-y") == 0) {
|
||||||
g_stConfInfo.consumeDelay = atol(argv[++i]);
|
g_stConfInfo.consumeDelay = atol(argv[++i]);
|
||||||
|
} else if (strcmp(argv[i], "-e") == 0) {
|
||||||
|
g_stConfInfo.useSnapshot = atol(argv[++i]);
|
||||||
} else {
|
} else {
|
||||||
pError("%s unknow para: %s %s", GREEN, argv[++i], NC);
|
pError("%s unknow para: %s %s", GREEN, argv[++i], NC);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -366,7 +365,8 @@ static char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, int32_t length, int32_t precision) {
|
static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* field, int32_t length,
|
||||||
|
int32_t precision) {
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
taosFprintfFile(pFile, "%s", TSDB_DATA_NULL_STR);
|
taosFprintfFile(pFile, "%s", TSDB_DATA_NULL_STR);
|
||||||
return;
|
return;
|
||||||
|
@ -429,7 +429,8 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dumpToFileForCheck(TdFilePtr pFile, TAOS_ROW row, TAOS_FIELD* fields, int32_t* length, int32_t num_fields, int32_t precision) {
|
static void dumpToFileForCheck(TdFilePtr pFile, TAOS_ROW row, TAOS_FIELD* fields, int32_t* length, int32_t num_fields,
|
||||||
|
int32_t precision) {
|
||||||
for (int32_t i = 0; i < num_fields; i++) {
|
for (int32_t i = 0; i < num_fields; i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
taosFprintfFile(pFile, "\n");
|
taosFprintfFile(pFile, "\n");
|
||||||
|
@ -448,7 +449,8 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex)
|
||||||
const char* dbName = tmq_get_db_name(msg);
|
const char* dbName = tmq_get_db_name(msg);
|
||||||
|
|
||||||
taosFprintfFile(g_fp, "consumerId: %d, msg index:%" PRId64 "\n", pInfo->consumerId, msgIndex);
|
taosFprintfFile(g_fp, "consumerId: %d, msg index:%" PRId64 "\n", pInfo->consumerId, msgIndex);
|
||||||
taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId: %d\n", dbName != NULL ? dbName : "invalid table", tmq_get_topic_name(msg), vgroupId);
|
taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId: %d\n", dbName != NULL ? dbName : "invalid table",
|
||||||
|
tmq_get_topic_name(msg), vgroupId);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
TAOS_ROW row = taos_fetch_row(msg);
|
TAOS_ROW row = taos_fetch_row(msg);
|
||||||
|
@ -471,6 +473,7 @@ static int32_t msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIndex)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision);
|
dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision);
|
||||||
|
|
||||||
taos_print_row(buf, row, fields, numOfFields);
|
taos_print_row(buf, row, fields, numOfFields);
|
||||||
|
|
||||||
if (0 != g_stConfInfo.showRowFlag) {
|
if (0 != g_stConfInfo.showRowFlag) {
|
||||||
|
@ -500,8 +503,7 @@ int queryDB(TAOS* taos, char* command) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void appNothing(void* param, TAOS_RES* res, int32_t numOfRows) {
|
static void appNothing(void* param, TAOS_RES* res, int32_t numOfRows) {}
|
||||||
}
|
|
||||||
|
|
||||||
int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) {
|
int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) {
|
||||||
char sqlStr[1024] = {0};
|
char sqlStr[1024] = {0};
|
||||||
|
@ -509,10 +511,7 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) {
|
||||||
int64_t now = taosGetTimestampMs();
|
int64_t now = taosGetTimestampMs();
|
||||||
|
|
||||||
// schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int
|
// schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int
|
||||||
sprintf(sqlStr, "insert into %s.notifyinfo values (%"PRId64", %d, %d)",
|
sprintf(sqlStr, "insert into %s.notifyinfo values (%" PRId64 ", %d, %d)", g_stConfInfo.cdbName, now, cmdId,
|
||||||
g_stConfInfo.cdbName,
|
|
||||||
now,
|
|
||||||
cmdId,
|
|
||||||
pInfo->consumerId);
|
pInfo->consumerId);
|
||||||
|
|
||||||
taos_query_a(pInfo->taos, sqlStr, appNothing, NULL);
|
taos_query_a(pInfo->taos, sqlStr, appNothing, NULL);
|
||||||
|
@ -564,6 +563,10 @@ void build_consumer(SThreadInfo* pInfo) {
|
||||||
// tmq_conf_set(conf, "auto.offset.reset", "none");
|
// tmq_conf_set(conf, "auto.offset.reset", "none");
|
||||||
// tmq_conf_set(conf, "auto.offset.reset", "earliest");
|
// tmq_conf_set(conf, "auto.offset.reset", "earliest");
|
||||||
// tmq_conf_set(conf, "auto.offset.reset", "latest");
|
// tmq_conf_set(conf, "auto.offset.reset", "latest");
|
||||||
|
//
|
||||||
|
if (g_stConfInfo.useSnapshot) {
|
||||||
|
tmq_conf_set(conf, "experiment.use.snapshot", "true");
|
||||||
|
}
|
||||||
|
|
||||||
pInfo->tmq = tmq_consumer_new(conf, NULL, 0);
|
pInfo->tmq = tmq_consumer_new(conf, NULL, 0);
|
||||||
|
|
||||||
|
@ -622,7 +625,8 @@ void loop_consume(SThreadInfo* pInfo) {
|
||||||
if (pInfo->ifCheckData) {
|
if (pInfo->ifCheckData) {
|
||||||
char filename[256] = {0};
|
char filename[256] = {0};
|
||||||
char tmpString[128];
|
char tmpString[128];
|
||||||
//sprintf(filename, "%s/../log/consumerid_%d_%s.txt", configDir, pInfo->consumerId, getCurrentTimeString(tmpString));
|
// sprintf(filename, "%s/../log/consumerid_%d_%s.txt", configDir, pInfo->consumerId,
|
||||||
|
// getCurrentTimeString(tmpString));
|
||||||
sprintf(filename, "%s/../log/consumerid_%d.txt", configDir, pInfo->consumerId);
|
sprintf(filename, "%s/../log/consumerid_%d.txt", configDir, pInfo->consumerId);
|
||||||
pInfo->pConsumeRowsFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
|
pInfo->pConsumeRowsFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
|
||||||
if (pInfo->pConsumeRowsFile == NULL) {
|
if (pInfo->pConsumeRowsFile == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue