Merge pull request #29142 from taosdata/enh/TD-32951
telemetry refactor
This commit is contained in:
commit
1b5f5cfd60
|
@ -62,7 +62,7 @@ After modifying configuration file parameters, you need to restart the *taosd* s
|
||||||
|telemetryReporting | |Supported, effective immediately |Whether to upload telemetry, 0: do not upload, 1: upload, default value 1|
|
|telemetryReporting | |Supported, effective immediately |Whether to upload telemetry, 0: do not upload, 1: upload, default value 1|
|
||||||
|telemetryServer | |Not supported |Telemetry server address|
|
|telemetryServer | |Not supported |Telemetry server address|
|
||||||
|telemetryPort | |Not supported |Telemetry server port number|
|
|telemetryPort | |Not supported |Telemetry server port number|
|
||||||
|telemetryInterval | |Supported, effective immediately |Telemetry upload interval, in seconds, default 43200|
|
|telemetryInterval | |Supported, effective immediately |Telemetry upload interval, in seconds, default 86400|
|
||||||
|crashReporting | |Supported, effective immediately |Whether to upload crash information; 0: do not upload, 1: upload; default value 1|
|
|crashReporting | |Supported, effective immediately |Whether to upload crash information; 0: do not upload, 1: upload; default value 1|
|
||||||
|
|
||||||
### Query Related
|
### Query Related
|
||||||
|
|
|
@ -59,7 +59,7 @@ taosd 命令行参数如下
|
||||||
|telemetryReporting | |支持动态修改 立即生效 |是否上传 telemetry,0:不上传,1:上传,默认值 1|
|
|telemetryReporting | |支持动态修改 立即生效 |是否上传 telemetry,0:不上传,1:上传,默认值 1|
|
||||||
|telemetryServer | |不支持动态修改 |telemetry 服务器地址|
|
|telemetryServer | |不支持动态修改 |telemetry 服务器地址|
|
||||||
|telemetryPort | |不支持动态修改 |telemetry 服务器端口编号|
|
|telemetryPort | |不支持动态修改 |telemetry 服务器端口编号|
|
||||||
|telemetryInterval | |支持动态修改 立即生效 |telemetry 上传时间间隔,单位为秒,默认 43200|
|
|telemetryInterval | |支持动态修改 立即生效 |telemetry 上传时间间隔,单位为秒,默认 86400|
|
||||||
|crashReporting | |支持动态修改 立即生效 |是否上传 crash 信息;0:不上传,1:上传;默认值 1|
|
|crashReporting | |支持动态修改 立即生效 |是否上传 crash 信息;0:不上传,1:上传;默认值 1|
|
||||||
|
|
||||||
### 查询相关
|
### 查询相关
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define _TD_UTIL_HTTP_H_
|
#define _TD_UTIL_HTTP_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tdef.h"
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -35,6 +36,21 @@ int32_t taosSendHttpReportByChan(const char* server, const char* uri, uint16_t p
|
||||||
EHttpCompFlag flag, int64_t chanId, const char* qid);
|
EHttpCompFlag flag, int64_t chanId, const char* qid);
|
||||||
void taosDestroyHttpChan(int64_t chanId);
|
void taosDestroyHttpChan(int64_t chanId);
|
||||||
|
|
||||||
|
int32_t taosSendRecvHttpReportWithQID(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
|
||||||
|
EHttpCompFlag flag, const char* qid, int64_t recvBufId);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char defaultAddr[256 + 1];
|
||||||
|
char cachedAddr[256 + 1];
|
||||||
|
int64_t recvBufRid;
|
||||||
|
} STelemAddrMgmt;
|
||||||
|
int32_t taosTelemetryMgtInit(STelemAddrMgmt* mgt, char* defaultAddr);
|
||||||
|
void taosTelemetryDestroy(STelemAddrMgmt* mgt);
|
||||||
|
|
||||||
|
// not safe for multi-thread, should be called in the same thread
|
||||||
|
int32_t taosSendTelemReport(STelemAddrMgmt* mgt, const char* uri, uint16_t port, char* pCont, int32_t contLen,
|
||||||
|
EHttpCompFlag flag);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -172,7 +172,8 @@ static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int
|
||||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType)));
|
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType)));
|
||||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(
|
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(
|
||||||
json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows)));
|
json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows)));
|
||||||
if (pRequest->sqlstr != NULL && strlen(pRequest->sqlstr) > pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen) {
|
if (pRequest->sqlstr != NULL &&
|
||||||
|
strlen(pRequest->sqlstr) > pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen) {
|
||||||
char tmp = pRequest->sqlstr[pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen];
|
char tmp = pRequest->sqlstr[pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen];
|
||||||
pRequest->sqlstr[pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen] = '\0';
|
pRequest->sqlstr[pTscObj->pAppInfo->serverCfg.monitorParas.tsSlowLogMaxLen] = '\0';
|
||||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
||||||
|
@ -802,6 +803,7 @@ void stopAllQueries(SRequestObj *pRequest) {
|
||||||
void crashReportThreadFuncUnexpectedStopped(void) { atomic_store_32(&clientStop, -1); }
|
void crashReportThreadFuncUnexpectedStopped(void) { atomic_store_32(&clientStop, -1); }
|
||||||
|
|
||||||
static void *tscCrashReportThreadFp(void *param) {
|
static void *tscCrashReportThreadFp(void *param) {
|
||||||
|
int32_t code = 0;
|
||||||
setThreadName("client-crashReport");
|
setThreadName("client-crashReport");
|
||||||
char filepath[PATH_MAX] = {0};
|
char filepath[PATH_MAX] = {0};
|
||||||
(void)snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
|
(void)snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
|
||||||
|
@ -822,6 +824,12 @@ static void *tscCrashReportThreadFp(void *param) {
|
||||||
if (-1 != atomic_val_compare_exchange_32(&clientStop, -1, 0)) {
|
if (-1 != atomic_val_compare_exchange_32(&clientStop, -1, 0)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
STelemAddrMgmt mgt;
|
||||||
|
code = taosTelemetryMgtInit(&mgt, tsTelemServer);
|
||||||
|
if (code) {
|
||||||
|
tscError("failed to init telemetry management, code:%s", tstrerror(code));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (clientStop > 0) break;
|
if (clientStop > 0) break;
|
||||||
|
@ -832,7 +840,7 @@ static void *tscCrashReportThreadFp(void *param) {
|
||||||
|
|
||||||
taosReadCrashInfo(filepath, &pMsg, &msgLen, &pFile);
|
taosReadCrashInfo(filepath, &pMsg, &msgLen, &pFile);
|
||||||
if (pMsg && msgLen > 0) {
|
if (pMsg && msgLen > 0) {
|
||||||
if (taosSendHttpReport(tsTelemServer, tsClientCrashReportUri, tsTelemPort, pMsg, msgLen, HTTP_FLAT) != 0) {
|
if (taosSendTelemReport(&mgt, tsClientCrashReportUri, tsTelemPort, pMsg, msgLen, HTTP_FLAT) != 0) {
|
||||||
tscError("failed to send crash report");
|
tscError("failed to send crash report");
|
||||||
if (pFile) {
|
if (pFile) {
|
||||||
taosReleaseCrashLogFile(pFile, false);
|
taosReleaseCrashLogFile(pFile, false);
|
||||||
|
@ -866,6 +874,7 @@ static void *tscCrashReportThreadFp(void *param) {
|
||||||
taosMsleep(sleepTime);
|
taosMsleep(sleepTime);
|
||||||
loopTimes = 0;
|
loopTimes = 0;
|
||||||
}
|
}
|
||||||
|
taosTelemetryDestroy(&mgt);
|
||||||
|
|
||||||
clientStop = -2;
|
clientStop = -2;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1107,7 +1116,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||||
*/
|
*/
|
||||||
uint64_t generateRequestId() {
|
uint64_t generateRequestId() {
|
||||||
static uint32_t hashId = 0;
|
static uint32_t hashId = 0;
|
||||||
static int32_t requestSerialId = 0;
|
static int32_t requestSerialId = 0;
|
||||||
|
|
||||||
if (hashId == 0) {
|
if (hashId == 0) {
|
||||||
int32_t code = taosGetSystemUUIDU32(&hashId);
|
int32_t code = taosGetSystemUUIDU32(&hashId);
|
||||||
|
|
|
@ -155,7 +155,7 @@ bool tsEnableTelem = false;
|
||||||
#else
|
#else
|
||||||
bool tsEnableTelem = true;
|
bool tsEnableTelem = true;
|
||||||
#endif
|
#endif
|
||||||
int32_t tsTelemInterval = 43200;
|
int32_t tsTelemInterval = 86400;
|
||||||
char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.tdengine.com";
|
char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.tdengine.com";
|
||||||
uint16_t tsTelemPort = 80;
|
uint16_t tsTelemPort = 80;
|
||||||
char *tsTelemUri = "/report";
|
char *tsTelemUri = "/report";
|
||||||
|
|
|
@ -254,6 +254,7 @@ static void *dmAuditThreadFp(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dmCrashReportThreadFp(void *param) {
|
static void *dmCrashReportThreadFp(void *param) {
|
||||||
|
int32_t code = 0;
|
||||||
SDnodeMgmt *pMgmt = param;
|
SDnodeMgmt *pMgmt = param;
|
||||||
int64_t lastTime = taosGetTimestampMs();
|
int64_t lastTime = taosGetTimestampMs();
|
||||||
setThreadName("dnode-crashReport");
|
setThreadName("dnode-crashReport");
|
||||||
|
@ -265,8 +266,14 @@ static void *dmCrashReportThreadFp(void *param) {
|
||||||
bool truncateFile = false;
|
bool truncateFile = false;
|
||||||
int32_t sleepTime = 200;
|
int32_t sleepTime = 200;
|
||||||
int32_t reportPeriodNum = 3600 * 1000 / sleepTime;
|
int32_t reportPeriodNum = 3600 * 1000 / sleepTime;
|
||||||
;
|
int32_t loopTimes = reportPeriodNum;
|
||||||
int32_t loopTimes = reportPeriodNum;
|
|
||||||
|
STelemAddrMgmt mgt = {0};
|
||||||
|
code = taosTelemetryMgtInit(&mgt, tsTelemServer);
|
||||||
|
if (code != 0) {
|
||||||
|
dError("failed to init telemetry since %s", tstrerror(code));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
if (pMgmt->pData->dropped || pMgmt->pData->stopped) break;
|
||||||
|
@ -277,7 +284,7 @@ static void *dmCrashReportThreadFp(void *param) {
|
||||||
|
|
||||||
taosReadCrashInfo(filepath, &pMsg, &msgLen, &pFile);
|
taosReadCrashInfo(filepath, &pMsg, &msgLen, &pFile);
|
||||||
if (pMsg && msgLen > 0) {
|
if (pMsg && msgLen > 0) {
|
||||||
if (taosSendHttpReport(tsTelemServer, tsSvrCrashReportUri, tsTelemPort, pMsg, msgLen, HTTP_FLAT) != 0) {
|
if (taosSendTelemReport(&mgt, tsSvrCrashReportUri, tsTelemPort, pMsg, msgLen, HTTP_FLAT) != 0) {
|
||||||
dError("failed to send crash report");
|
dError("failed to send crash report");
|
||||||
if (pFile) {
|
if (pFile) {
|
||||||
taosReleaseCrashLogFile(pFile, false);
|
taosReleaseCrashLogFile(pFile, false);
|
||||||
|
@ -311,6 +318,7 @@ static void *dmCrashReportThreadFp(void *param) {
|
||||||
taosMsleep(sleepTime);
|
taosMsleep(sleepTime);
|
||||||
loopTimes = 0;
|
loopTimes = 0;
|
||||||
}
|
}
|
||||||
|
taosTelemetryDestroy(&mgt);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tgrant.h"
|
#include "tgrant.h"
|
||||||
|
#include "thttp.h"
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -80,8 +81,9 @@ typedef struct {
|
||||||
} SProfileMgmt;
|
} SProfileMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
TdThreadMutex lock;
|
TdThreadMutex lock;
|
||||||
char email[TSDB_FQDN_LEN];
|
char email[TSDB_FQDN_LEN];
|
||||||
|
STelemAddrMgmt addrMgt;
|
||||||
} STelemMgmt;
|
} STelemMgmt;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -411,7 +411,7 @@ void mndDoTimerPullupTask(SMnode *pMnode, int64_t sec) {
|
||||||
mndStreamConsensusChkpt(pMnode);
|
mndStreamConsensusChkpt(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sec % tsTelemInterval == (TMIN(60, (tsTelemInterval - 1)))) {
|
if (sec % tsTelemInterval == (TMIN(86400, (tsTelemInterval - 1)))) {
|
||||||
mndPullupTelem(pMnode);
|
mndPullupTelem(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,8 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t line = 0;
|
||||||
SMnode* pMnode = pReq->info.node;
|
SMnode* pMnode = pReq->info.node;
|
||||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||||
if (!tsEnableTelem) return 0;
|
if (!tsEnableTelem) return 0;
|
||||||
|
@ -140,15 +142,18 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
||||||
char* pCont = mndBuildTelemetryReport(pMnode);
|
char* pCont = mndBuildTelemetryReport(pMnode);
|
||||||
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
||||||
|
|
||||||
if (pCont != NULL) {
|
if (pCont == NULL) {
|
||||||
if (taosSendHttpReport(tsTelemServer, tsTelemUri, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) {
|
return 0;
|
||||||
mError("failed to send telemetry report");
|
|
||||||
} else {
|
|
||||||
mInfo("succeed to send telemetry report");
|
|
||||||
}
|
|
||||||
taosMemoryFree(pCont);
|
|
||||||
}
|
}
|
||||||
return 0;
|
code = taosSendTelemReport(&pMgmt->addrMgt, tsTelemUri, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT);
|
||||||
|
taosMemoryFree(pCont);
|
||||||
|
return code;
|
||||||
|
_end:
|
||||||
|
if (code != 0) {
|
||||||
|
mError("%s failed to send at line %d since %s", __func__, line, tstrerror(code));
|
||||||
|
}
|
||||||
|
taosMemoryFree(pCont);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndInitTelem(SMnode* pMnode) {
|
int32_t mndInitTelem(SMnode* pMnode) {
|
||||||
|
@ -158,6 +163,11 @@ int32_t mndInitTelem(SMnode* pMnode) {
|
||||||
(void)taosThreadMutexInit(&pMgmt->lock, NULL);
|
(void)taosThreadMutexInit(&pMgmt->lock, NULL);
|
||||||
if ((code = taosGetEmail(pMgmt->email, sizeof(pMgmt->email))) != 0)
|
if ((code = taosGetEmail(pMgmt->email, sizeof(pMgmt->email))) != 0)
|
||||||
mWarn("failed to get email since %s", tstrerror(code));
|
mWarn("failed to get email since %s", tstrerror(code));
|
||||||
|
code = taosTelemetryMgtInit(&pMgmt->addrMgt, tsTelemServer);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to init telemetry management since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer);
|
mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -165,5 +175,6 @@ int32_t mndInitTelem(SMnode* pMnode) {
|
||||||
|
|
||||||
void mndCleanupTelem(SMnode* pMnode) {
|
void mndCleanupTelem(SMnode* pMnode) {
|
||||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||||
|
taosTelemetryDestroy(&pMgmt->addrMgt);
|
||||||
(void)taosThreadMutexDestroy(&pMgmt->lock);
|
(void)taosThreadMutexDestroy(&pMgmt->lock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ static int32_t FAST_FAILURE_LIMIT = 1;
|
||||||
static int64_t httpDefaultChanId = -1;
|
static int64_t httpDefaultChanId = -1;
|
||||||
|
|
||||||
static int64_t httpSeqNum = 0;
|
static int64_t httpSeqNum = 0;
|
||||||
|
static int32_t httpRecvRefMgt = 0;
|
||||||
|
|
||||||
typedef struct SHttpModule {
|
typedef struct SHttpModule {
|
||||||
uv_loop_t* loop;
|
uv_loop_t* loop;
|
||||||
|
@ -54,6 +55,8 @@ typedef struct SHttpMsg {
|
||||||
int64_t chanId;
|
int64_t chanId;
|
||||||
int64_t seq;
|
int64_t seq;
|
||||||
char* qid;
|
char* qid;
|
||||||
|
|
||||||
|
int64_t recvBufRid;
|
||||||
} SHttpMsg;
|
} SHttpMsg;
|
||||||
|
|
||||||
typedef struct SHttpClient {
|
typedef struct SHttpClient {
|
||||||
|
@ -67,6 +70,8 @@ typedef struct SHttpClient {
|
||||||
struct sockaddr_in dest;
|
struct sockaddr_in dest;
|
||||||
int64_t chanId;
|
int64_t chanId;
|
||||||
int64_t seq;
|
int64_t seq;
|
||||||
|
|
||||||
|
int64_t recvBufRid;
|
||||||
} SHttpClient;
|
} SHttpClient;
|
||||||
|
|
||||||
typedef struct SHttpConnList {
|
typedef struct SHttpConnList {
|
||||||
|
@ -74,6 +79,13 @@ typedef struct SHttpConnList {
|
||||||
|
|
||||||
} SHttpConnList;
|
} SHttpConnList;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char* pBuf;
|
||||||
|
int32_t nBuf;
|
||||||
|
SRWLatch latch;
|
||||||
|
int8_t inited;
|
||||||
|
} SHttpRecvBuf;
|
||||||
|
|
||||||
static TdThreadOnce transHttpInit = PTHREAD_ONCE_INIT;
|
static TdThreadOnce transHttpInit = PTHREAD_ONCE_INIT;
|
||||||
static void transHttpEnvInit();
|
static void transHttpEnvInit();
|
||||||
|
|
||||||
|
@ -94,6 +106,9 @@ static void httpModuleDestroy(SHttpModule* http);
|
||||||
static int32_t taosSendHttpReportImplByChan(const char* server, const char* uri, uint16_t port, char* pCont,
|
static int32_t taosSendHttpReportImplByChan(const char* server, const char* uri, uint16_t port, char* pCont,
|
||||||
int32_t contLen, EHttpCompFlag flag, int64_t chanId, const char* qid);
|
int32_t contLen, EHttpCompFlag flag, int64_t chanId, const char* qid);
|
||||||
|
|
||||||
|
static int32_t taosSendHttpReportImplByChan2(const char* server, const char* uri, uint16_t port, char* pCont,
|
||||||
|
int32_t contLen, EHttpCompFlag flag, int64_t chanId, const char* qid,
|
||||||
|
int64_t rid);
|
||||||
static int32_t taosBuildHttpHeader(const char* server, const char* uri, int32_t contLen, const char* qid, char* pHead,
|
static int32_t taosBuildHttpHeader(const char* server, const char* uri, int32_t contLen, const char* qid, char* pHead,
|
||||||
int32_t headLen,
|
int32_t headLen,
|
||||||
|
|
||||||
|
@ -394,6 +409,8 @@ static FORCE_INLINE void destroyHttpClient(SHttpClient* cli) {
|
||||||
taosMemoryFree(cli->wbuf);
|
taosMemoryFree(cli->wbuf);
|
||||||
taosMemoryFree(cli->rbuf);
|
taosMemoryFree(cli->rbuf);
|
||||||
taosMemoryFree(cli->addr);
|
taosMemoryFree(cli->addr);
|
||||||
|
// taosFreeHttpRecvHandle(cli->recvBufRid);
|
||||||
|
|
||||||
taosMemoryFree(cli);
|
taosMemoryFree(cli);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,6 +440,28 @@ static FORCE_INLINE void clientRecvCb(uv_stream_t* handle, ssize_t nread, const
|
||||||
tError("http-report recv error:%s, seq:%" PRId64 "", uv_strerror(nread), cli->seq);
|
tError("http-report recv error:%s, seq:%" PRId64 "", uv_strerror(nread), cli->seq);
|
||||||
} else {
|
} else {
|
||||||
tTrace("http-report succ to recv %d bytes, seq:%" PRId64 "", (int32_t)nread, cli->seq);
|
tTrace("http-report succ to recv %d bytes, seq:%" PRId64 "", (int32_t)nread, cli->seq);
|
||||||
|
if (cli->recvBufRid > 0) {
|
||||||
|
SHttpRecvBuf* p = taosAcquireRef(httpRecvRefMgt, cli->recvBufRid);
|
||||||
|
if (p != NULL) {
|
||||||
|
taosWLockLatch(&p->latch);
|
||||||
|
if (p->inited != 0) {
|
||||||
|
tDebug("http-report already recv valid data");
|
||||||
|
} else {
|
||||||
|
p->pBuf = taosMemoryCalloc(1, nread + 1);
|
||||||
|
if (p->pBuf != NULL) {
|
||||||
|
memcpy(p->pBuf, buf->base, nread);
|
||||||
|
p->nBuf = nread;
|
||||||
|
p->inited = 1;
|
||||||
|
} else {
|
||||||
|
tError("http-report failed to dump recv since %s", tstrerror(terrno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosWUnLockLatch(&p->latch);
|
||||||
|
TAOS_UNUSED(taosReleaseRef(httpRecvRefMgt, cli->recvBufRid));
|
||||||
|
} else {
|
||||||
|
tWarn("http-report failed to acquire recv buf since %s", tstrerror(terrno));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!uv_is_closing((uv_handle_t*)&cli->tcp)) {
|
if (!uv_is_closing((uv_handle_t*)&cli->tcp)) {
|
||||||
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
|
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
|
||||||
|
@ -629,6 +668,8 @@ static void httpHandleReq(SHttpMsg* msg) {
|
||||||
cli->chanId = chanId;
|
cli->chanId = chanId;
|
||||||
cli->addr = msg->server;
|
cli->addr = msg->server;
|
||||||
cli->port = msg->port;
|
cli->port = msg->port;
|
||||||
|
cli->recvBufRid = msg->recvBufRid;
|
||||||
|
|
||||||
if (msg->qid != NULL) taosMemoryFree(msg->qid);
|
if (msg->qid != NULL) taosMemoryFree(msg->qid);
|
||||||
taosMemoryFree(msg->uri);
|
taosMemoryFree(msg->uri);
|
||||||
taosMemoryFree(msg);
|
taosMemoryFree(msg);
|
||||||
|
@ -714,6 +755,47 @@ void httpModuleDestroy2(SHttpModule* http) {
|
||||||
taosMemoryFree(http);
|
taosMemoryFree(http);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t taosSendHttpReportImplByChan2(const char* server, const char* uri, uint16_t port, char* pCont,
|
||||||
|
int32_t contLen, EHttpCompFlag flag, int64_t chanId, const char* qid,
|
||||||
|
int64_t recvBufRid) {
|
||||||
|
SHttpModule* load = NULL;
|
||||||
|
SHttpMsg* msg = NULL;
|
||||||
|
int32_t code = httpCreateMsg(server, uri, port, pCont, contLen, flag, chanId, qid, &msg);
|
||||||
|
if (code != 0) {
|
||||||
|
goto _ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg->recvBufRid = recvBufRid;
|
||||||
|
|
||||||
|
load = taosAcquireRef(httpRefMgt, chanId);
|
||||||
|
if (load == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
goto _ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (atomic_load_8(&load->quit)) {
|
||||||
|
code = TSDB_CODE_HTTP_MODULE_QUIT;
|
||||||
|
goto _ERROR;
|
||||||
|
}
|
||||||
|
tDebug("http-report start to report, chanId:%" PRId64 ", seq:%" PRId64 "", chanId, msg->seq);
|
||||||
|
|
||||||
|
code = transAsyncSend(load->asyncPool, &(msg->q));
|
||||||
|
if (code != 0) {
|
||||||
|
code = TSDB_CODE_HTTP_MODULE_QUIT;
|
||||||
|
goto _ERROR;
|
||||||
|
}
|
||||||
|
msg = NULL;
|
||||||
|
|
||||||
|
_ERROR:
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
tError("http-report failed to report reason:%s, chanId:%" PRId64 ", seq:%" PRId64 "", tstrerror(code), chanId,
|
||||||
|
msg->seq);
|
||||||
|
}
|
||||||
|
httpDestroyMsg(msg);
|
||||||
|
if (load != NULL) taosReleaseRef(httpRefMgt, chanId);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
static int32_t taosSendHttpReportImplByChan(const char* server, const char* uri, uint16_t port, char* pCont,
|
static int32_t taosSendHttpReportImplByChan(const char* server, const char* uri, uint16_t port, char* pCont,
|
||||||
int32_t contLen, EHttpCompFlag flag, int64_t chanId, const char* qid) {
|
int32_t contLen, EHttpCompFlag flag, int64_t chanId, const char* qid) {
|
||||||
SHttpModule* load = NULL;
|
SHttpModule* load = NULL;
|
||||||
|
@ -769,20 +851,34 @@ int32_t taosSendHttpReportWithQID(const char* server, const char* uri, uint16_t
|
||||||
return taosSendHttpReportImplByChan(server, uri, port, pCont, contLen, flag, httpDefaultChanId, qid);
|
return taosSendHttpReportImplByChan(server, uri, port, pCont, contLen, flag, httpDefaultChanId, qid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t taosSendRecvHttpReportWithQID(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
|
||||||
|
EHttpCompFlag flag, const char* qid, int64_t recvBufId) {
|
||||||
|
TAOS_UNUSED(taosThreadOnce(&transHttpInit, transHttpEnvInit));
|
||||||
|
return taosSendHttpReportImplByChan2(server, uri, port, pCont, contLen, flag, httpDefaultChanId, qid, recvBufId);
|
||||||
|
}
|
||||||
|
|
||||||
static void transHttpDestroyHandle(void* handle) { taosMemoryFree(handle); }
|
static void transHttpDestroyHandle(void* handle) { taosMemoryFree(handle); }
|
||||||
|
|
||||||
|
static void transHttpDestroyRecvHandle(void* handle) {
|
||||||
|
SHttpRecvBuf* p = handle;
|
||||||
|
taosMemoryFree(p->pBuf);
|
||||||
|
taosMemoryFree(p);
|
||||||
|
}
|
||||||
|
|
||||||
int64_t transInitHttpChanImpl();
|
int64_t transInitHttpChanImpl();
|
||||||
|
|
||||||
static void transHttpEnvInit() {
|
static void transHttpEnvInit() {
|
||||||
httpRefMgt = taosOpenRef(64, transHttpDestroyHandle);
|
httpRefMgt = taosOpenRef(64, transHttpDestroyHandle);
|
||||||
httpDefaultChanId = transInitHttpChanImpl();
|
httpDefaultChanId = transInitHttpChanImpl();
|
||||||
httpSeqNum = 0;
|
httpSeqNum = 0;
|
||||||
|
httpRecvRefMgt = taosOpenRef(8, transHttpDestroyRecvHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transHttpEnvDestroy() {
|
void transHttpEnvDestroy() {
|
||||||
// remove default chanId
|
// remove default chanId
|
||||||
taosDestroyHttpChan(httpDefaultChanId);
|
taosDestroyHttpChan(httpDefaultChanId);
|
||||||
httpDefaultChanId = -1;
|
httpDefaultChanId = -1;
|
||||||
|
taosCloseRef(httpRecvRefMgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t transInitHttpChanImpl() {
|
int64_t transInitHttpChanImpl() {
|
||||||
|
@ -868,3 +964,158 @@ void taosDestroyHttpChan(int64_t chanId) {
|
||||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||||
TAOS_UNUSED(taosRemoveRef(httpRefMgt, chanId));
|
TAOS_UNUSED(taosRemoveRef(httpRefMgt, chanId));
|
||||||
}
|
}
|
||||||
|
static int32_t taosAllocHttpRecvHandle(int64_t* rid) {
|
||||||
|
TAOS_UNUSED(taosThreadOnce(&transHttpInit, transHttpEnvInit));
|
||||||
|
SHttpRecvBuf* p = taosMemoryCalloc(1, sizeof(SHttpRecvBuf));
|
||||||
|
if (p == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
taosInitRWLatch(&p->latch);
|
||||||
|
|
||||||
|
int64_t id = taosAddRef(httpRecvRefMgt, p);
|
||||||
|
if (taosAcquireRef(httpRecvRefMgt, id) == NULL) {
|
||||||
|
taosMemoryFree(p);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
*rid = id;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static void taosFreeHttpRecvHandle(int64_t rid) {
|
||||||
|
if (rid <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TAOS_UNUSED(taosReleaseRef(httpRecvRefMgt, rid));
|
||||||
|
TAOS_UNUSED(taosRemoveRef(httpRecvRefMgt, rid));
|
||||||
|
}
|
||||||
|
static int32_t taosGetHttpRecvById(int64_t rid, char** pRecv, int32_t* len) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SHttpRecvBuf* p = taosAcquireRef(httpRecvRefMgt, rid);
|
||||||
|
if (p == NULL) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
taosWLockLatch(&p->latch);
|
||||||
|
if (p->inited) {
|
||||||
|
*pRecv = p->pBuf;
|
||||||
|
*len = p->nBuf;
|
||||||
|
p->pBuf = 0;
|
||||||
|
p->nBuf = 0;
|
||||||
|
} else {
|
||||||
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
taosWUnLockLatch(&p->latch);
|
||||||
|
TAOS_UNUSED(taosReleaseRef(httpRecvRefMgt, rid));
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t taosTelemetryMgtInit(STelemAddrMgmt* mgt, char* defaultAddr) {
|
||||||
|
tstrncpy(mgt->defaultAddr, defaultAddr, sizeof(mgt->defaultAddr));
|
||||||
|
mgt->cachedAddr[0] = 0;
|
||||||
|
mgt->recvBufRid = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void taosTelemetryDestroy(STelemAddrMgmt* mgt) {
|
||||||
|
if (mgt == NULL || mgt->recvBufRid <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
taosFreeHttpRecvHandle(mgt->recvBufRid);
|
||||||
|
mgt->recvBufRid = 0;
|
||||||
|
}
|
||||||
|
// TODO: parse http response head By LIB
|
||||||
|
static int32_t taosTelemetryGetValueFromHttpResp(const char* response, const char* key, char* val) {
|
||||||
|
if (key == NULL || val == NULL) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = 0, line = 0;
|
||||||
|
int32_t len = strlen(key);
|
||||||
|
int32_t cap = len + 16;
|
||||||
|
// const char* reportUrlKey = "\"report_url\":\"";
|
||||||
|
|
||||||
|
char* buf = taosMemoryCalloc(1, cap);
|
||||||
|
if (buf == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
int32_t nBytes = snprintf(buf, cap, "\"%s\":\"", key);
|
||||||
|
if ((uint32_t)nBytes >= cap) {
|
||||||
|
TAOS_CHECK_GOTO(TSDB_CODE_INVALID_PARA, &line, _end);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* start = strstr(response, buf);
|
||||||
|
if (start) {
|
||||||
|
start += strlen(buf);
|
||||||
|
char* end = strchr(start, '"');
|
||||||
|
if (end && end - start > 0) {
|
||||||
|
tstrncpy(val, start, end - start + 1);
|
||||||
|
} else {
|
||||||
|
TAOS_CHECK_GOTO(TSDB_CODE_INVALID_PARA, &line, _end);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
TAOS_CHECK_GOTO(TSDB_CODE_INVALID_PARA, &line, _end);
|
||||||
|
}
|
||||||
|
_end:
|
||||||
|
if (code != 0) {
|
||||||
|
tError("failed to get value from http response since %s", tstrerror(code));
|
||||||
|
}
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
static int32_t taosGetAddrFromHttpResp(int64_t recvBufRid, char* telemAddr) {
|
||||||
|
int32_t code = 0;
|
||||||
|
char* pRecv = NULL;
|
||||||
|
int32_t nRecv = 0;
|
||||||
|
|
||||||
|
code = taosGetHttpRecvById(recvBufRid, &pRecv, &nRecv);
|
||||||
|
if (code != 0) {
|
||||||
|
tError("failed to get http recv buf since %s", tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = taosTelemetryGetValueFromHttpResp(pRecv, "report_url", telemAddr);
|
||||||
|
taosMemoryFree(pRecv);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
int32_t taosSendTelemReport(STelemAddrMgmt* mgt, const char* uri, uint16_t port, char* pCont, int32_t contLen,
|
||||||
|
EHttpCompFlag flag) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t line = 0;
|
||||||
|
int32_t sendMsg = 0;
|
||||||
|
char* addr = mgt->defaultAddr;
|
||||||
|
if (mgt->cachedAddr[0] == 0) {
|
||||||
|
if (mgt->recvBufRid == 0) {
|
||||||
|
code = taosAllocHttpRecvHandle(&mgt->recvBufRid);
|
||||||
|
TAOS_CHECK_GOTO(code, &line, _end);
|
||||||
|
code = taosSendRecvHttpReportWithQID(mgt->defaultAddr, uri, port, pCont, contLen, flag, NULL, mgt->recvBufRid);
|
||||||
|
TAOS_CHECK_GOTO(code, &line, _end);
|
||||||
|
} else {
|
||||||
|
code = taosGetAddrFromHttpResp(mgt->recvBufRid, mgt->cachedAddr);
|
||||||
|
if (code != 0) {
|
||||||
|
tError("failed to get cache addr from http response since %s", tstrerror(code));
|
||||||
|
addr = mgt->defaultAddr;
|
||||||
|
} else {
|
||||||
|
addr = mgt->cachedAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mgt->recvBufRid > 0) {
|
||||||
|
taosFreeHttpRecvHandle(mgt->recvBufRid);
|
||||||
|
mgt->recvBufRid = 0;
|
||||||
|
}
|
||||||
|
sendMsg = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addr = mgt->cachedAddr;
|
||||||
|
sendMsg = 1;
|
||||||
|
}
|
||||||
|
if (sendMsg == 1) {
|
||||||
|
code = taosSendHttpReport(addr, uri, port, pCont, contLen, flag);
|
||||||
|
}
|
||||||
|
tDebug("send telemetry port oldAddr:[%s], newAddr:[%s]", mgt->defaultAddr, mgt->cachedAddr);
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_end:
|
||||||
|
if (code != 0) {
|
||||||
|
tError("failed to send telemetry since %s, default addr:%s, cachedAddr:%s", tstrerror(code), mgt->defaultAddr,
|
||||||
|
mgt->cachedAddr);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "transLog.h"
|
#include "transLog.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "tversion.h"
|
#include "tversion.h"
|
||||||
|
#include "thttp.h"
|
||||||
|
#include "tjson.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const char *label = "APP";
|
const char *label = "APP";
|
||||||
|
@ -515,7 +517,7 @@ TEST_F(TransEnv, idTest) {
|
||||||
TEST_F(TransEnv, noResp) {
|
TEST_F(TransEnv, noResp) {
|
||||||
SRpcMsg resp = {0};
|
SRpcMsg resp = {0};
|
||||||
SRpcMsg req = {0};
|
SRpcMsg req = {0};
|
||||||
for (int i = 0; i < 500000; i++) {
|
for (int i = 0; i < 50000; i++) {
|
||||||
memset(&req, 0, sizeof(req));
|
memset(&req, 0, sizeof(req));
|
||||||
req.info.noResp = 0;
|
req.info.noResp = 0;
|
||||||
req.msgType = 3;
|
req.msgType = 3;
|
||||||
|
@ -527,3 +529,107 @@ TEST_F(TransEnv, noResp) {
|
||||||
taosMsleep(10000);
|
taosMsleep(10000);
|
||||||
// no resp
|
// no resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TransEnv, http) {
|
||||||
|
int32_t code = 0;
|
||||||
|
char tmp[4096] = {0};
|
||||||
|
int32_t lino = 0;
|
||||||
|
SJson* pJson = tjsonCreateObject();
|
||||||
|
|
||||||
|
char clusterName[64] = {0};
|
||||||
|
tjsonAddStringToObject(pJson, "instanceId", clusterName);
|
||||||
|
tjsonAddDoubleToObject(pJson, "reportVersion", 1);
|
||||||
|
|
||||||
|
if (taosGetOsReleaseName(tmp, NULL, NULL, sizeof(tmp)) == 0) {
|
||||||
|
tjsonAddStringToObject(pJson, "os", tmp);
|
||||||
|
}
|
||||||
|
char *pCont = NULL;
|
||||||
|
int32_t len = 0;
|
||||||
|
|
||||||
|
float numOfCores = 0;
|
||||||
|
if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores) == 0) {
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "cpuModel", tmp), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores), &lino, _OVER);
|
||||||
|
} else {
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores), &lino, _OVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "memory", tmp), &lino, _OVER);
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "version", td_version), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "buildInfo", td_buildinfo), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "gitInfo", td_gitinfo), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "email", "test126.com"), &lino, _OVER);
|
||||||
|
|
||||||
|
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfDnode",1 ), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfMnode", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfVgroup", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfDatabase", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfSuperTable", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfChildTable", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfColumn", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "numOfPoint", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "totalStorage", 1), &lino, _OVER);
|
||||||
|
TAOS_CHECK_GOTO(tjsonAddDoubleToObject(pJson, "compStorage", 1), &lino, _OVER);
|
||||||
|
|
||||||
|
pCont = tjsonToString(pJson);
|
||||||
|
len = strlen(pCont);
|
||||||
|
tjsonDelete(pJson);
|
||||||
|
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
STelemAddrMgmt mgt;
|
||||||
|
taosTelemetryMgtInit(&mgt, "telemetry.tdengine.com");
|
||||||
|
int32_t code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, pCont, len,HTTP_FLAT);
|
||||||
|
|
||||||
|
taosMsleep(2000);
|
||||||
|
code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, pCont, len,HTTP_FLAT);
|
||||||
|
printf("old addr:%s new addr:%s\n",mgt.defaultAddr, mgt.cachedAddr);
|
||||||
|
for (int32_t i = 0; i < 10; i++) {
|
||||||
|
code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, pCont, len,HTTP_FLAT);
|
||||||
|
|
||||||
|
printf("old addr:%s new addr:%s\n",mgt.defaultAddr, mgt.cachedAddr);
|
||||||
|
taosMsleep(2000);
|
||||||
|
}
|
||||||
|
taosTelemetryDestroy(&mgt);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
STelemAddrMgmt mgt;
|
||||||
|
taosTelemetryMgtInit(&mgt, "telemetry.taosdata.com");
|
||||||
|
int32_t code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, "test", strlen("test"),HTTP_FLAT);
|
||||||
|
printf("old addr:%s new addr:%s\n",mgt.defaultAddr, mgt.cachedAddr);
|
||||||
|
|
||||||
|
taosMsleep(2000);
|
||||||
|
code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, pCont, len,HTTP_FLAT);
|
||||||
|
for (int32_t i = 0; i < 10; i++) {
|
||||||
|
code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, pCont, len,HTTP_FLAT);
|
||||||
|
printf("old addr:%s new addr:%s\n",mgt.defaultAddr, mgt.cachedAddr);
|
||||||
|
taosMsleep(2000);
|
||||||
|
}
|
||||||
|
taosTelemetryDestroy(&mgt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
{
|
||||||
|
STelemAddrMgmt mgt;
|
||||||
|
taosTelemetryMgtInit(&mgt, "error");
|
||||||
|
int32_t code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, "test", strlen("test"),HTTP_FLAT);
|
||||||
|
|
||||||
|
taosMsleep(2000);
|
||||||
|
code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, "test", strlen("test"),HTTP_FLAT);
|
||||||
|
for (int32_t i = 0; i < 10; i++) {
|
||||||
|
code = taosSendTelemReport(&mgt,tsTelemUri, tsTelemPort, "test", strlen("test"),HTTP_FLAT);
|
||||||
|
taosMsleep(2000);
|
||||||
|
|
||||||
|
}
|
||||||
|
taosTelemetryDestroy(&mgt);
|
||||||
|
|
||||||
|
}
|
||||||
|
_OVER:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue