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