TDengine/source/libs/sync/src/syncIO.c

474 lines
14 KiB
C
Raw Normal View History

2022-02-26 18:24:50 +00:00
/*
* 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/>.
*/
#include "syncIO.h"
2022-03-04 05:25:39 +00:00
#include <tdatablock.h>
2022-05-14 11:54:18 +00:00
#include "os.h"
2022-03-09 07:07:43 +00:00
#include "syncMessage.h"
2022-03-12 09:02:15 +00:00
#include "syncUtil.h"
2022-02-26 18:24:50 +00:00
#include "tglobal.h"
#include "ttimer.h"
#include "tutil.h"
2022-02-27 02:22:15 +00:00
SSyncIO *gSyncIO = NULL;
2022-02-28 06:10:34 +00:00
// local function ------------
2022-03-02 07:11:54 +00:00
static SSyncIO *syncIOCreate(char *host, uint16_t port);
static int32_t syncIODestroy(SSyncIO *io);
2022-03-12 09:02:15 +00:00
static int32_t syncIOStartInternal(SSyncIO *io);
static int32_t syncIOStopInternal(SSyncIO *io);
2022-03-02 07:11:54 +00:00
2022-06-25 17:16:11 +00:00
static void * syncIOConsumerFunc(void *param);
2022-03-12 09:02:15 +00:00
static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet);
static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet);
static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey);
static int32_t syncIOStartQ(SSyncIO *io);
static int32_t syncIOStopQ(SSyncIO *io);
static int32_t syncIOStartPing(SSyncIO *io);
static int32_t syncIOStopPing(SSyncIO *io);
static void syncIOTickQ(void *param, void *tmrId);
static void syncIOTickPing(void *param, void *tmrId);
2022-02-28 06:10:34 +00:00
// ----------------------------
2022-03-02 07:11:54 +00:00
// public function ------------
int32_t syncIOStart(char *host, uint16_t port) {
2022-03-12 09:02:15 +00:00
int32_t ret = 0;
2022-03-02 07:11:54 +00:00
gSyncIO = syncIOCreate(host, port);
2022-06-21 08:02:36 +00:00
ASSERT(gSyncIO != NULL);
2022-02-28 06:10:34 +00:00
2022-03-11 08:49:07 +00:00
taosSeedRand(taosGetTimestampSec());
2022-03-12 09:02:15 +00:00
ret = syncIOStartInternal(gSyncIO);
2022-06-21 08:02:36 +00:00
ASSERT(ret == 0);
2022-03-01 12:29:49 +00:00
2022-03-12 09:02:15 +00:00
sTrace("syncIOStart ok, gSyncIO:%p", gSyncIO);
return ret;
2022-02-28 06:10:34 +00:00
}
2022-02-26 18:24:50 +00:00
2022-03-02 07:11:54 +00:00
int32_t syncIOStop() {
int32_t ret = syncIOStopInternal(gSyncIO);
2022-06-21 08:02:36 +00:00
ASSERT(ret == 0);
2022-02-26 18:24:50 +00:00
2022-03-02 07:11:54 +00:00
ret = syncIODestroy(gSyncIO);
2022-06-21 08:02:36 +00:00
ASSERT(ret == 0);
2022-02-26 18:24:50 +00:00
return ret;
}
2022-05-19 11:44:01 +00:00
int32_t syncIOSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
2022-06-21 08:02:36 +00:00
ASSERT(pEpSet->inUse == 0);
ASSERT(pEpSet->numOfEps == 1);
2022-02-26 18:24:50 +00:00
2022-03-12 09:02:15 +00:00
int32_t ret = 0;
2022-04-18 13:50:56 +00:00
{
syncUtilMsgNtoH(pMsg->pCont);
char logBuf[256] = {0};
2022-06-02 03:36:26 +00:00
snprintf(logBuf, sizeof(logBuf), "==syncIOSendMsg== %s:%d msgType:%d", pEpSet->eps[0].fqdn, pEpSet->eps[0].port,
pMsg->msgType);
2022-04-18 13:50:56 +00:00
syncRpcMsgLog2(logBuf, pMsg);
syncUtilMsgHtoN(pMsg->pCont);
}
2022-02-28 08:36:57 +00:00
2022-05-16 07:17:11 +00:00
pMsg->info.handle = NULL;
pMsg->info.noResp = 1;
2022-05-19 11:44:01 +00:00
rpcSendRequest(gSyncIO->clientRpc, pEpSet, pMsg, NULL);
2022-03-12 09:02:15 +00:00
return ret;
2022-03-04 07:48:09 +00:00
}
2022-05-19 11:44:01 +00:00
int32_t syncIOEqMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
2022-03-12 09:02:15 +00:00
int32_t ret = 0;
2022-06-04 03:25:03 +00:00
char logBuf[256] = {0};
snprintf(logBuf, sizeof(logBuf), "==syncIOEqMsg== msgType:%d", pMsg->msgType);
syncRpcMsgLog2(logBuf, pMsg);
2022-03-12 09:02:15 +00:00
2022-03-04 07:48:09 +00:00
SRpcMsg *pTemp;
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
2022-03-04 07:48:09 +00:00
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
2022-05-19 11:44:01 +00:00
STaosQueue *pMsgQ = gSyncIO->pMsgQ;
2022-03-04 07:48:09 +00:00
taosWriteQitem(pMsgQ, pTemp);
2022-03-12 09:02:15 +00:00
return ret;
}
int32_t syncIOQTimerStart() {
int32_t ret = syncIOStartQ(gSyncIO);
2022-06-21 08:02:36 +00:00
ASSERT(ret == 0);
2022-03-12 09:02:15 +00:00
return ret;
}
int32_t syncIOQTimerStop() {
int32_t ret = syncIOStopQ(gSyncIO);
2022-06-21 08:02:36 +00:00
ASSERT(ret == 0);
2022-03-12 09:02:15 +00:00
return ret;
}
int32_t syncIOPingTimerStart() {
int32_t ret = syncIOStartPing(gSyncIO);
2022-06-21 08:02:36 +00:00
ASSERT(ret == 0);
2022-03-12 09:02:15 +00:00
return ret;
}
int32_t syncIOPingTimerStop() {
int32_t ret = syncIOStopPing(gSyncIO);
2022-06-21 08:02:36 +00:00
ASSERT(ret == 0);
2022-03-12 09:02:15 +00:00
return ret;
2022-03-04 07:48:09 +00:00
}
2022-03-02 07:11:54 +00:00
// local function ------------
2022-03-12 09:02:15 +00:00
static SSyncIO *syncIOCreate(char *host, uint16_t port) {
2022-03-25 16:29:53 +00:00
SSyncIO *io = (SSyncIO *)taosMemoryMalloc(sizeof(SSyncIO));
2022-03-12 09:02:15 +00:00
memset(io, 0, sizeof(*io));
io->pMsgQ = taosOpenQueue();
io->pQset = taosOpenQset();
taosAddIntoQset(io->pQset, io->pMsgQ, NULL);
io->myAddr.inUse = 0;
io->myAddr.numOfEps = 0;
addEpIntoEpSet(&io->myAddr, host, port);
io->qTimerMS = TICK_Q_TIMER_MS;
io->pingTimerMS = TICK_Ping_TIMER_MS;
return io;
}
static int32_t syncIODestroy(SSyncIO *io) {
int32_t ret = 0;
int8_t start = atomic_load_8(&io->isStart);
2022-06-21 08:02:36 +00:00
ASSERT(start == 0);
2022-03-12 09:02:15 +00:00
if (io->serverRpc != NULL) {
rpcClose(io->serverRpc);
io->serverRpc = NULL;
}
if (io->clientRpc != NULL) {
rpcClose(io->clientRpc);
io->clientRpc = NULL;
}
taosCloseQueue(io->pMsgQ);
taosCloseQset(io->pQset);
return ret;
}
2022-03-02 07:11:54 +00:00
static int32_t syncIOStartInternal(SSyncIO *io) {
2022-03-12 09:02:15 +00:00
int32_t ret = 0;
2022-02-26 18:24:50 +00:00
taosBlockSIGPIPE();
2022-03-02 07:11:54 +00:00
rpcInit();
2022-02-26 18:24:50 +00:00
// cient rpc init
{
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localPort = 0;
rpcInit.label = "SYNC-IO-CLIENT";
rpcInit.numOfThreads = 1;
2022-03-02 07:11:54 +00:00
rpcInit.cfp = syncIOProcessReply;
2022-02-26 18:24:50 +00:00
rpcInit.sessions = 100;
rpcInit.idleTime = 100;
rpcInit.user = "sync-io";
rpcInit.connType = TAOS_CONN_CLIENT;
io->clientRpc = rpcOpen(&rpcInit);
if (io->clientRpc == NULL) {
sError("failed to initialize RPC");
return -1;
}
}
// server rpc init
{
SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit));
2022-05-14 10:12:53 +00:00
snprintf(rpcInit.localFqdn, sizeof(rpcInit.localFqdn), "%s", "127.0.0.1");
2022-03-02 08:37:04 +00:00
rpcInit.localPort = io->myAddr.eps[0].port;
2022-02-26 18:24:50 +00:00
rpcInit.label = "SYNC-IO-SERVER";
rpcInit.numOfThreads = 1;
2022-03-02 07:11:54 +00:00
rpcInit.cfp = syncIOProcessRequest;
2022-02-26 18:24:50 +00:00
rpcInit.sessions = 1000;
rpcInit.idleTime = 2 * 1500;
rpcInit.parent = io;
rpcInit.connType = TAOS_CONN_SERVER;
void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) {
sError("failed to start RPC server");
return -1;
}
}
// start consumer thread
{
2022-03-19 16:47:45 +00:00
if (taosThreadCreate(&io->consumerTid, NULL, syncIOConsumerFunc, io) != 0) {
2022-02-26 18:24:50 +00:00
sError("failed to create sync consumer thread since %s", strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
}
// start tmr thread
2022-03-12 09:02:15 +00:00
io->timerMgr = taosTmrInit(1000, 50, 10000, "SYNC-IO");
2022-02-26 18:24:50 +00:00
2022-03-12 09:02:15 +00:00
atomic_store_8(&io->isStart, 1);
return ret;
2022-02-26 18:24:50 +00:00
}
2022-03-02 07:11:54 +00:00
static int32_t syncIOStopInternal(SSyncIO *io) {
2022-03-12 09:02:15 +00:00
int32_t ret = 0;
2022-02-26 18:24:50 +00:00
atomic_store_8(&io->isStart, 0);
2022-03-19 16:47:45 +00:00
taosThreadJoin(io->consumerTid, NULL);
taosThreadClear(&io->consumerTid);
2022-03-12 09:02:15 +00:00
taosTmrCleanUp(io->timerMgr);
return ret;
2022-03-02 07:11:54 +00:00
}
static void *syncIOConsumerFunc(void *param) {
SSyncIO *io = param;
STaosQall *qall = taosAllocateQall();
SRpcMsg *pRpcMsg, rpcMsg;
SQueueInfo qinfo = {0};
2022-03-02 07:11:54 +00:00
while (1) {
int numOfMsgs = taosReadAllQitemsFromQset(io->pQset, qall, &qinfo);
2022-03-02 07:11:54 +00:00
sTrace("syncIOConsumerFunc %d msgs are received", numOfMsgs);
2022-03-09 10:33:41 +00:00
if (numOfMsgs <= 0) {
break;
}
2022-03-02 07:11:54 +00:00
for (int i = 0; i < numOfMsgs; ++i) {
taosGetQitem(qall, (void **)&pRpcMsg);
2022-06-01 16:00:27 +00:00
char logBuf[128];
2022-06-04 03:25:03 +00:00
snprintf(logBuf, sizeof(logBuf), "==syncIOConsumMsg== msgType:%d", pRpcMsg->msgType);
2022-06-01 16:00:27 +00:00
syncRpcMsgLog2(logBuf, pRpcMsg);
2022-03-09 10:33:41 +00:00
2022-03-12 09:02:15 +00:00
// use switch case instead of if else
if (pRpcMsg->msgType == TDMT_SYNC_PING) {
2022-03-02 07:11:54 +00:00
if (io->FpOnSyncPing != NULL) {
2022-03-12 09:02:15 +00:00
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-03-12 09:02:15 +00:00
io->FpOnSyncPing(io->pSyncNode, pSyncMsg);
syncPingDestroy(pSyncMsg);
2022-03-02 07:11:54 +00:00
}
2022-03-02 11:56:15 +00:00
} else if (pRpcMsg->msgType == TDMT_SYNC_PING_REPLY) {
2022-03-02 12:43:03 +00:00
if (io->FpOnSyncPingReply != NULL) {
2022-03-12 09:02:15 +00:00
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-03-02 12:43:03 +00:00
io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg);
2022-03-04 07:48:09 +00:00
syncPingReplyDestroy(pSyncMsg);
2022-03-02 12:43:03 +00:00
}
2022-03-04 08:54:25 +00:00
} else if (pRpcMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
2022-03-15 06:07:45 +00:00
if (io->FpOnSyncClientRequest != NULL) {
SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-06-25 12:31:42 +00:00
io->FpOnSyncClientRequest(io->pSyncNode, pSyncMsg, NULL);
2022-03-15 06:07:45 +00:00
syncClientRequestDestroy(pSyncMsg);
}
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE) {
2022-03-09 10:33:41 +00:00
if (io->FpOnSyncRequestVote != NULL) {
2022-03-12 09:02:15 +00:00
SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-03-06 04:25:12 +00:00
io->FpOnSyncRequestVote(io->pSyncNode, pSyncMsg);
syncRequestVoteDestroy(pSyncMsg);
}
} else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) {
2022-03-09 10:33:41 +00:00
if (io->FpOnSyncRequestVoteReply != NULL) {
2022-03-12 09:02:15 +00:00
SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-03-06 04:25:12 +00:00
io->FpOnSyncRequestVoteReply(io->pSyncNode, pSyncMsg);
syncRequestVoteReplyDestroy(pSyncMsg);
}
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES) {
2022-03-09 10:33:41 +00:00
if (io->FpOnSyncAppendEntries != NULL) {
2022-03-12 09:02:15 +00:00
SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-03-06 04:25:12 +00:00
io->FpOnSyncAppendEntries(io->pSyncNode, pSyncMsg);
syncAppendEntriesDestroy(pSyncMsg);
}
} else if (pRpcMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_REPLY) {
2022-03-09 10:33:41 +00:00
if (io->FpOnSyncAppendEntriesReply != NULL) {
2022-03-12 09:02:15 +00:00
SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-03-06 04:25:12 +00:00
io->FpOnSyncAppendEntriesReply(io->pSyncNode, pSyncMsg);
syncAppendEntriesReplyDestroy(pSyncMsg);
}
} else if (pRpcMsg->msgType == TDMT_SYNC_TIMEOUT) {
2022-03-05 04:28:34 +00:00
if (io->FpOnSyncTimeout != NULL) {
2022-03-12 09:02:15 +00:00
SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-03-05 04:28:34 +00:00
io->FpOnSyncTimeout(io->pSyncNode, pSyncMsg);
syncTimeoutDestroy(pSyncMsg);
}
2022-06-01 13:23:39 +00:00
} else if (pRpcMsg->msgType == TDMT_SYNC_SNAPSHOT_SEND) {
2022-06-01 13:23:39 +00:00
if (io->FpOnSyncSnapshotSend != NULL) {
SyncSnapshotSend *pSyncMsg = syncSnapshotSendFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-06-01 13:23:39 +00:00
io->FpOnSyncSnapshotSend(io->pSyncNode, pSyncMsg);
syncSnapshotSendDestroy(pSyncMsg);
}
} else if (pRpcMsg->msgType == TDMT_SYNC_SNAPSHOT_RSP) {
2022-06-01 13:23:39 +00:00
if (io->FpOnSyncSnapshotRsp != NULL) {
SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pRpcMsg);
2022-06-21 08:02:36 +00:00
ASSERT(pSyncMsg != NULL);
2022-06-01 13:23:39 +00:00
io->FpOnSyncSnapshotRsp(io->pSyncNode, pSyncMsg);
syncSnapshotRspDestroy(pSyncMsg);
}
2022-03-05 04:28:34 +00:00
} else {
2022-03-12 09:02:15 +00:00
sTrace("unknown msgType:%d, no operator", pRpcMsg->msgType);
2022-03-02 07:11:54 +00:00
}
}
taosResetQitems(qall);
for (int i = 0; i < numOfMsgs; ++i) {
taosGetQitem(qall, (void **)&pRpcMsg);
rpcFreeCont(pRpcMsg->pCont);
2022-03-24 11:40:37 +00:00
/*
if (pRpcMsg->handle != NULL) {
int msgSize = 32;
memset(&rpcMsg, 0, sizeof(rpcMsg));
rpcMsg.msgType = SYNC_RESPONSE;
rpcMsg.pCont = rpcMallocCont(msgSize);
rpcMsg.contLen = msgSize;
snprintf(rpcMsg.pCont, rpcMsg.contLen, "%s", "give a reply");
rpcMsg.handle = pRpcMsg->handle;
rpcMsg.code = 0;
2022-04-18 13:50:56 +00:00
syncRpcMsgLog2((char *)"syncIOConsumerFunc rpcSendResponse --> ", &rpcMsg);
2022-03-24 11:40:37 +00:00
rpcSendResponse(&rpcMsg);
}
*/
2022-03-02 07:11:54 +00:00
taosFreeQitem(pRpcMsg);
}
taosUpdateItemSize(qinfo.queue, numOfMsgs);
2022-02-26 18:24:50 +00:00
}
2022-03-02 07:11:54 +00:00
taosFreeQall(qall);
return NULL;
}
static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
2022-04-18 13:50:56 +00:00
syncUtilMsgNtoH(pMsg->pCont);
syncRpcMsgLog2((char *)"==syncIOProcessRequest==", pMsg);
2022-03-02 07:11:54 +00:00
SSyncIO *io = pParent;
SRpcMsg *pTemp;
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
2022-03-02 07:11:54 +00:00
memcpy(pTemp, pMsg, sizeof(SRpcMsg));
taosWriteQitem(io->pMsgQ, pTemp);
}
static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) {
if (pMsg->msgType == TDMT_SYNC_COMMON_RESPONSE) {
2022-03-12 09:02:15 +00:00
sTrace("==syncIOProcessReply==");
} else {
2022-04-18 13:50:56 +00:00
syncRpcMsgLog2((char *)"==syncIOProcessReply==", pMsg);
2022-03-12 09:02:15 +00:00
}
2022-03-02 07:11:54 +00:00
rpcFreeCont(pMsg->pCont);
}
2022-03-12 09:02:15 +00:00
static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey) {
// app shall retrieve the auth info based on meterID from DB or a data file
// demo code here only for simple demo
int32_t ret = 0;
return ret;
}
static int32_t syncIOStartQ(SSyncIO *io) {
int32_t ret = 0;
taosTmrReset(syncIOTickQ, io->qTimerMS, io, io->timerMgr, &io->qTimer);
return ret;
}
static int32_t syncIOStopQ(SSyncIO *io) {
int32_t ret = 0;
taosTmrStop(io->qTimer);
io->qTimer = NULL;
return ret;
}
static int32_t syncIOStartPing(SSyncIO *io) {
int32_t ret = 0;
taosTmrReset(syncIOTickPing, io->pingTimerMS, io, io->timerMgr, &io->pingTimer);
return ret;
}
static int32_t syncIOStopPing(SSyncIO *io) {
int32_t ret = 0;
taosTmrStop(io->pingTimer);
io->pingTimer = NULL;
return ret;
2022-02-27 02:22:15 +00:00
}
2022-03-02 07:11:54 +00:00
2022-03-12 09:02:15 +00:00
static void syncIOTickQ(void *param, void *tmrId) {
2022-03-02 07:11:54 +00:00
SSyncIO *io = (SSyncIO *)param;
2022-03-12 09:02:15 +00:00
SRaftId srcId, destId;
srcId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port);
srcId.vgId = -1;
destId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port);
destId.vgId = -1;
2022-04-18 13:50:56 +00:00
SyncPingReply *pMsg = syncPingReplyBuild2(&srcId, &destId, -1, "syncIOTickQ");
2022-03-02 07:11:54 +00:00
2022-03-12 09:02:15 +00:00
SRpcMsg rpcMsg;
syncPingReply2RpcMsg(pMsg, &rpcMsg);
2022-03-02 07:11:54 +00:00
SRpcMsg *pTemp;
pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM);
2022-03-02 07:11:54 +00:00
memcpy(pTemp, &rpcMsg, sizeof(SRpcMsg));
2022-04-18 13:50:56 +00:00
syncRpcMsgLog2((char *)"==syncIOTickQ==", &rpcMsg);
2022-03-02 07:11:54 +00:00
taosWriteQitem(io->pMsgQ, pTemp);
2022-03-12 09:02:15 +00:00
syncPingReplyDestroy(pMsg);
taosTmrReset(syncIOTickQ, io->qTimerMS, io, io->timerMgr, &io->qTimer);
2022-03-02 07:11:54 +00:00
}
2022-03-12 09:02:15 +00:00
static void syncIOTickPing(void *param, void *tmrId) {
SSyncIO *io = (SSyncIO *)param;
SRaftId srcId, destId;
srcId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port);
srcId.vgId = -1;
destId.addr = syncUtilAddr2U64(io->myAddr.eps[0].fqdn, io->myAddr.eps[0].port);
destId.vgId = -1;
2022-04-18 13:50:56 +00:00
SyncPing *pMsg = syncPingBuild2(&srcId, &destId, -1, "syncIOTickPing");
2022-03-12 09:02:15 +00:00
// SyncPing *pMsg = syncPingBuild3(&srcId, &destId);
SRpcMsg rpcMsg;
syncPing2RpcMsg(pMsg, &rpcMsg);
2022-04-18 13:50:56 +00:00
syncRpcMsgLog2((char *)"==syncIOTickPing==", &rpcMsg);
2022-03-12 09:02:15 +00:00
rpcSendRequest(io->clientRpc, &io->myAddr, &rpcMsg, NULL);
syncPingDestroy(pMsg);
taosTmrReset(syncIOTickPing, io->pingTimerMS, io, io->timerMgr, &io->pingTimer);
2022-04-23 10:29:45 +00:00
}