ping test
This commit is contained in:
parent
a78d7028ef
commit
76c4fce8d0
|
@ -211,23 +211,17 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
if (pRpcMsg->msgType == SYNC_PING) {
|
||||
if (io->FpOnSyncPing != NULL) {
|
||||
SyncPing *pSyncMsg;
|
||||
|
||||
SRpcMsg tmpRpcMsg;
|
||||
memcpy(&tmpRpcMsg, pRpcMsg, sizeof(SRpcMsg));
|
||||
pSyncMsg = syncPingBuild(tmpRpcMsg.contLen);
|
||||
|
||||
pSyncMsg = syncPingBuild(pRpcMsg->contLen);
|
||||
syncPingFromRpcMsg(pRpcMsg, pSyncMsg);
|
||||
|
||||
// memcpy(pSyncMsg, tmpRpcMsg.pCont, tmpRpcMsg.contLen);
|
||||
|
||||
io->FpOnSyncPing(io->pSyncNode, pSyncMsg);
|
||||
}
|
||||
|
||||
} else if (pRpcMsg->msgType == SYNC_PING_REPLY) {
|
||||
SyncPingReply *pSyncMsg = syncPingReplyBuild(pRpcMsg->contLen);
|
||||
syncPingReplyFromRpcMsg(pRpcMsg, pSyncMsg);
|
||||
|
||||
if (io->FpOnSyncPingReply != NULL) {
|
||||
SyncPingReply *pSyncMsg;
|
||||
pSyncMsg = syncPingReplyBuild(pRpcMsg->contLen);
|
||||
syncPingReplyFromRpcMsg(pRpcMsg, pSyncMsg);
|
||||
io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -171,16 +171,6 @@ static int32_t syncNodePing(SSyncNode* pSyncNode, const SRaftId* destRaftId, Syn
|
|||
|
||||
SRpcMsg rpcMsg;
|
||||
syncPing2RpcMsg(pMsg, &rpcMsg);
|
||||
|
||||
/*
|
||||
SRpcMsg rpcMsg;
|
||||
rpcMsg.contLen = 64;
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
snprintf((char*)rpcMsg.pCont, rpcMsg.contLen, "%s", "xxxxxxxxxxxxxx");
|
||||
rpcMsg.handle = NULL;
|
||||
rpcMsg.msgType = 1;
|
||||
*/
|
||||
|
||||
syncNodeSendMsgById(destRaftId, pSyncNode, &rpcMsg);
|
||||
|
||||
{
|
||||
|
|
|
@ -13,7 +13,9 @@ void logTest() {
|
|||
sFatal("--- sync log test: fatal");
|
||||
}
|
||||
|
||||
SSyncNode* doSync() {
|
||||
uint16_t ports[3] = {7010, 7110, 7210};
|
||||
|
||||
SSyncNode* doSync(int myIndex) {
|
||||
SSyncFSM* pFsm;
|
||||
|
||||
SSyncInfo syncInfo;
|
||||
|
@ -24,18 +26,18 @@ SSyncNode* doSync() {
|
|||
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./test_sync_ping");
|
||||
|
||||
SSyncCfg* pCfg = &syncInfo.syncCfg;
|
||||
pCfg->myIndex = 0;
|
||||
pCfg->replicaNum = 2;
|
||||
pCfg->myIndex = myIndex;
|
||||
pCfg->replicaNum = 3;
|
||||
|
||||
pCfg->nodeInfo[0].nodePort = 7010;
|
||||
pCfg->nodeInfo[0].nodePort = ports[0];
|
||||
snprintf(pCfg->nodeInfo[0].nodeFqdn, sizeof(pCfg->nodeInfo[0].nodeFqdn), "%s", "127.0.0.1");
|
||||
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
|
||||
|
||||
pCfg->nodeInfo[1].nodePort = 7110;
|
||||
pCfg->nodeInfo[1].nodePort = ports[1];
|
||||
snprintf(pCfg->nodeInfo[1].nodeFqdn, sizeof(pCfg->nodeInfo[1].nodeFqdn), "%s", "127.0.0.1");
|
||||
// taosGetFqdn(pCfg->nodeInfo[1].nodeFqdn);
|
||||
|
||||
pCfg->nodeInfo[2].nodePort = 7210;
|
||||
pCfg->nodeInfo[2].nodePort = ports[2];
|
||||
snprintf(pCfg->nodeInfo[2].nodeFqdn, sizeof(pCfg->nodeInfo[2].nodeFqdn), "%s", "127.0.0.1");
|
||||
// taosGetFqdn(pCfg->nodeInfo[2].nodeFqdn);
|
||||
|
||||
|
@ -53,20 +55,25 @@ void timerPingAll(void* param, void* tmrId) {
|
|||
syncNodePingAll(pSyncNode);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int argc, char** argv) {
|
||||
// taosInitLog((char*)"syncPingTest.log", 100000, 10);
|
||||
tsAsyncLog = 0;
|
||||
sDebugFlag = 143 + 64;
|
||||
|
||||
logTest();
|
||||
|
||||
int32_t ret = syncIOStart((char*)"127.0.0.1", 7010);
|
||||
int myIndex = 0;
|
||||
if (argc >= 2) {
|
||||
myIndex = atoi(argv[1]);
|
||||
}
|
||||
|
||||
int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]);
|
||||
assert(ret == 0);
|
||||
|
||||
ret = syncEnvStart();
|
||||
assert(ret == 0);
|
||||
|
||||
SSyncNode* pSyncNode = doSync();
|
||||
SSyncNode* pSyncNode = doSync(myIndex);
|
||||
gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing;
|
||||
gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply;
|
||||
|
||||
|
@ -74,9 +81,9 @@ int main() {
|
|||
assert(ret == 0);
|
||||
|
||||
/*
|
||||
taosMsleep(10000);
|
||||
ret = syncNodeStopPingTimer(pSyncNode);
|
||||
assert(ret == 0);
|
||||
taosMsleep(10000);
|
||||
ret = syncNodeStopPingTimer(pSyncNode);
|
||||
assert(ret == 0);
|
||||
*/
|
||||
|
||||
while (1) {
|
||||
|
|
Loading…
Reference in New Issue